Skip to content

Commit f27a5ea

Browse files
committed
updated gh actions
1 parent c80b144 commit f27a5ea

2 files changed

Lines changed: 50 additions & 12 deletions

File tree

.github/workflows/dockerize.yaml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,52 @@ name: Build and push Docker images
33
on:
44
push:
55
tags: '@openfn/ws-worker@**'
6+
workflow_call:
67

78
jobs:
8-
build-and-push-worker-image:
9-
name: Push Docker image to Docker Hub
9+
check-tag:
10+
name: Check if Docker tag exists
1011
runs-on: ubuntu-latest
12+
outputs:
13+
should_build: ${{ steps.check.outputs.should_build }}
14+
docker_tag: ${{ steps.extract.outputs.docker_tag }}
1115
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
- name: Manipulate tag for docker
15-
id: branch_name
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Extract Docker tag
20+
id: extract
1621
run: |
17-
SOURCE_TAG=${GITHUB_REF#refs/tags/}
22+
SOURCE_TAG=$(git tag --sort=-creatordate --list "@openfn/ws-worker@*" | head -n 1)
1823
echo Source Tag: $SOURCE_TAG
1924
2025
VERSION_TAG=${SOURCE_TAG#@openfn/ws-worker}
2126
echo Version Tag: $VERSION_TAG
22-
27+
2328
DOCKER_TAG=${VERSION_TAG#@}
2429
echo Docker Tag: $DOCKER_TAG
25-
26-
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
30+
31+
echo "docker_tag=$DOCKER_TAG" >> $GITHUB_OUTPUT
32+
- name: Check if Docker tag exists
33+
id: check
34+
run: |
35+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
36+
https://hub.docker.com/v2/repositories/openfn/ws-worker/tags/v${{ steps.extract.outputs.docker_tag }}/)
37+
if [ "$STATUS" = "200" ]; then
38+
echo "Tag v${{ steps.extract.outputs.docker_tag }} already exists on Docker Hub, skipping build"
39+
echo "should_build=false" >> $GITHUB_OUTPUT
40+
else
41+
echo "should_build=true" >> $GITHUB_OUTPUT
42+
fi
43+
44+
build-and-push-worker-image:
45+
needs: check-tag
46+
if: needs.check-tag.outputs.should_build == 'true'
47+
name: Push Docker image to Docker Hub
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
2752
- name: Set up QEMU
2853
uses: docker/setup-qemu-action@v3
2954
- name: Set up Docker Buildx
@@ -41,4 +66,4 @@ jobs:
4166
target: ws-worker
4267
tags: |
4368
openfn/ws-worker:latest
44-
openfn/ws-worker:v${{ env.DOCKER_TAG }}
69+
openfn/ws-worker:v${{ needs.check-tag.outputs.docker_tag }}

.github/workflows/publish.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
publish:
99
runs-on: ubuntu-latest
10+
outputs:
11+
ws_worker_tagged: ${{ steps.tags.outputs.ws_worker_tagged }}
1012
steps:
1113
- uses: actions/checkout@v6
1214
with:
@@ -27,8 +29,19 @@ jobs:
2729
- run: git config user.email ${{ secrets.GH_EMAIL }}
2830

2931
- name: Push tags
30-
run: pnpm changeset tag && git push --tags
32+
id: tags
33+
run: |
34+
pnpm changeset tag
35+
if git tag -l '@openfn/ws-worker@*' | grep -q .; then
36+
echo "ws_worker_tagged=true" >> $GITHUB_OUTPUT
37+
fi
38+
git push --tags
3139
3240
- run: pnpm run generate-slack-report
3341
env:
3442
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
43+
44+
dockerize:
45+
needs: publish
46+
uses: ./.github/workflows/dockerize.yaml
47+
secrets: inherit

0 commit comments

Comments
 (0)