-
Notifications
You must be signed in to change notification settings - Fork 36
65 lines (60 loc) · 2.08 KB
/
Copy pathdocker-release.yml
File metadata and controls
65 lines (60 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Build and Push Docker Image
on:
workflow_call:
inputs:
version:
required: true
type: string
description: "Version tag for the Docker image"
jobs:
check-if-latest:
runs-on: ubuntu-latest
outputs:
is_latest: ${{ steps.check_latest.outputs.is_latest }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get current release tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
# Check if the current tag is the latest release tag
- name: Check if this is the latest release
id: check_latest
run: |
latest_tag=$(
curl -L \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/cdisc-org/cdisc-rules-engine/releases/latest \
| jq -r '.tag_name'
)
current_tag="${GITHUB_REF#refs/tags/}"
if [[ "$latest_tag" == "$current_tag" ]]; then
echo "is_latest=true" >> $GITHUB_OUTPUT
echo "This is the latest release: $latest_tag"
else
echo "is_latest=false" >> $GITHUB_OUTPUT
echo "This is NOT the latest release. Latest is: $latest_tag, current is: $current_tag"
fi
build-and-push:
needs: check-if-latest
if: needs.check-if-latest.outputs.is_latest == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.check-if-latest.outputs.version }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
cdiscdocker/cdisc-rules-engine:latest
cdiscdocker/cdisc-rules-engine:${{ needs.check-if-latest.outputs.version }}