From f27a5ea1247ad6dd819cd167fc123a48d58cf4f7 Mon Sep 17 00:00:00 2001 From: Joe Clark Date: Thu, 19 Mar 2026 17:14:15 +0000 Subject: [PATCH] updated gh actions --- .github/workflows/dockerize.yaml | 47 ++++++++++++++++++++++++-------- .github/workflows/publish.yaml | 15 +++++++++- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dockerize.yaml b/.github/workflows/dockerize.yaml index 42fa1dae5..ffd65203e 100644 --- a/.github/workflows/dockerize.yaml +++ b/.github/workflows/dockerize.yaml @@ -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 @@ -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 }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index db47e6c6c..7776658a2 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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: @@ -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