Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions .github/workflows/dockerize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,52 @@ name: Build and push Docker images
on:
push:
tags: '@openfn/ws-worker@**'
workflow_call:

jobs:
build-and-push-worker-image:
name: Push Docker image to Docker Hub
check-tag:
name: Check if Docker tag exists
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
docker_tag: ${{ steps.extract.outputs.docker_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Manipulate tag for docker
id: branch_name
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract Docker tag
id: extract
run: |
SOURCE_TAG=${GITHUB_REF#refs/tags/}
SOURCE_TAG=$(git tag --sort=-creatordate --list "@openfn/ws-worker@*" | head -n 1)
echo Source Tag: $SOURCE_TAG

VERSION_TAG=${SOURCE_TAG#@openfn/ws-worker}
echo Version Tag: $VERSION_TAG

DOCKER_TAG=${VERSION_TAG#@}
echo Docker Tag: $DOCKER_TAG

echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV

echo "docker_tag=$DOCKER_TAG" >> $GITHUB_OUTPUT
- name: Check if Docker tag exists
id: check
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
https://hub.docker.com/v2/repositories/openfn/ws-worker/tags/v${{ steps.extract.outputs.docker_tag }}/)
if [ "$STATUS" = "200" ]; then
echo "Tag v${{ steps.extract.outputs.docker_tag }} already exists on Docker Hub, skipping build"
echo "should_build=false" >> $GITHUB_OUTPUT
else
echo "should_build=true" >> $GITHUB_OUTPUT
fi

build-and-push-worker-image:
needs: check-tag
if: needs.check-tag.outputs.should_build == 'true'
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -41,4 +66,4 @@ jobs:
target: ws-worker
tags: |
openfn/ws-worker:latest
openfn/ws-worker:v${{ env.DOCKER_TAG }}
openfn/ws-worker:v${{ needs.check-tag.outputs.docker_tag }}
15 changes: 14 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
outputs:
ws_worker_tagged: ${{ steps.tags.outputs.ws_worker_tagged }}
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -27,8 +29,19 @@ jobs:
- run: git config user.email ${{ secrets.GH_EMAIL }}

- name: Push tags
run: pnpm changeset tag && git push --tags
id: tags
run: |
pnpm changeset tag
if git tag -l '@openfn/ws-worker@*' | grep -q .; then
echo "ws_worker_tagged=true" >> $GITHUB_OUTPUT
fi
git push --tags

- run: pnpm run generate-slack-report
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}

dockerize:
needs: publish
uses: ./.github/workflows/dockerize.yaml
secrets: inherit