chore(ci): add ACT guards to skip DockerHub steps in local act runs

act sets ACT=true automatically. Guards added:
- docker login: if: ${{ !env.ACT }}
- build outputs: type=docker (local load) when ACT, push-by-digest when CI
- digest export/upload: if: ${{ !env.ACT }}
- merge job: if: ${{ !env.ACT }}
- release-helm job (docker.yml): if: ${{ !env.ACT }}
- version-bump git push (docker.yml): wrapped in [ -z "$ACT" ] shell guard

Run locally with:
  ./bin/act -j build -W .github/workflows/docker.yml \
    -P ubuntu-latest=catthehacker/ubuntu:act-latest
This commit is contained in:
jubnl
2026-05-25 21:05:47 +02:00
parent 3f760338c8
commit 797183de08
2 changed files with 22 additions and 9 deletions
+5 -1
View File
@@ -87,6 +87,7 @@ jobs:
- uses: docker/setup-buildx-action@v3 - uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3 - uses: docker/login-action@v3
if: ${{ !env.ACT }}
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -97,18 +98,20 @@ jobs:
with: with:
context: . context: .
platforms: ${{ matrix.platform }} platforms: ${{ matrix.platform }}
outputs: type=image,name=mauriceboe/trek,push-by-digest=true,name-canonical=true,push=true outputs: ${{ env.ACT == 'true' && 'type=docker' || 'type=image,name=mauriceboe/trek,push-by-digest=true,name-canonical=true,push=true' }}
no-cache: true no-cache: true
build-args: | build-args: |
APP_VERSION=${{ needs.version-bump.outputs.version }} APP_VERSION=${{ needs.version-bump.outputs.version }}
- name: Export digest - name: Export digest
if: ${{ !env.ACT }}
run: | run: |
mkdir -p /tmp/digests mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}" digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}" touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest artifact - name: Upload digest artifact
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: digests-${{ env.PLATFORM_PAIR }} name: digests-${{ env.PLATFORM_PAIR }}
@@ -117,6 +120,7 @@ jobs:
retention-days: 1 retention-days: 1
merge: merge:
if: ${{ !env.ACT }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [version-bump, build] needs: [version-bump, build]
steps: steps:
+17 -8
View File
@@ -107,13 +107,15 @@ jobs:
sed -i "s/^version: .*/version: $NEW_VERSION/" charts/trek/Chart.yaml sed -i "s/^version: .*/version: $NEW_VERSION/" charts/trek/Chart.yaml
sed -i "s/^appVersion: .*/appVersion: \"$NEW_VERSION\"/" charts/trek/Chart.yaml sed -i "s/^appVersion: .*/appVersion: \"$NEW_VERSION\"/" charts/trek/Chart.yaml
# Commit and tag # Commit and tag (skipped when running locally with act)
git config user.name "github-actions[bot]" if [ -z "$ACT" ]; then
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.name "github-actions[bot]"
git add package.json package-lock.json server/package.json client/package.json shared/package.json charts/trek/Chart.yaml git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "chore: bump version to $NEW_VERSION [skip ci]" git add package.json package-lock.json server/package.json client/package.json shared/package.json charts/trek/Chart.yaml
git tag "v$NEW_VERSION" git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
git push origin main --follow-tags git tag "v$NEW_VERSION"
git push origin main --follow-tags
fi
build: build:
runs-on: ${{ matrix.runner }} runs-on: ${{ matrix.runner }}
@@ -137,6 +139,7 @@ jobs:
- uses: docker/setup-buildx-action@v3 - uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3 - uses: docker/login-action@v3
if: ${{ !env.ACT }}
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -147,18 +150,22 @@ jobs:
with: with:
context: . context: .
platforms: ${{ matrix.platform }} platforms: ${{ matrix.platform }}
outputs: type=image,name=mauriceboe/trek,push-by-digest=true,name-canonical=true,push=true # act (local): load image into local Docker daemon instead of pushing.
# CI: push by digest to Docker Hub for multi-arch manifest assembly.
outputs: ${{ env.ACT == 'true' && 'type=docker' || 'type=image,name=mauriceboe/trek,push-by-digest=true,name-canonical=true,push=true' }}
no-cache: true no-cache: true
build-args: | build-args: |
APP_VERSION=${{ needs.version-bump.outputs.version }} APP_VERSION=${{ needs.version-bump.outputs.version }}
- name: Export digest - name: Export digest
if: ${{ !env.ACT }}
run: | run: |
mkdir -p /tmp/digests mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}" digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}" touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest artifact - name: Upload digest artifact
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: digests-${{ env.PLATFORM_PAIR }} name: digests-${{ env.PLATFORM_PAIR }}
@@ -167,6 +174,7 @@ jobs:
retention-days: 1 retention-days: 1
merge: merge:
if: ${{ !env.ACT }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [version-bump, build] needs: [version-bump, build]
steps: steps:
@@ -204,6 +212,7 @@ jobs:
run: docker buildx imagetools inspect mauriceboe/trek:latest run: docker buildx imagetools inspect mauriceboe/trek:latest
release-helm: release-helm:
if: ${{ !env.ACT }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: version-bump needs: version-bump
steps: steps: