Skip to content

Commit f65449b

Browse files
chore: 🧺 Update workflow
1 parent 8d4621d commit f65449b

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

.github/workflows/docker.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,19 @@ jobs:
3030
with:
3131
filters: |
3232
backend:
33-
- 'apps/wizarr-backend/**'
34-
- 'apps/wizarr-backend'
33+
- 'apps/wizarr-backend/**'
34+
- 'apps/wizarr-backend'
3535
frontend:
36-
- 'apps/wizarr-frontend/**'
37-
- 'apps/wizarr-frontend'
36+
- 'apps/wizarr-frontend/**'
37+
- 'apps/wizarr-frontend'
3838
- name: Check if we should force jobs to run
3939
id: should_force
4040
run: echo "should_force=${{ github.event_name == 'workflow_dispatch' || github.event_name == 'release' }}" >> "$GITHUB_OUTPUT"
4141

4242
retag:
4343
name: Re-Tag ${{ matrix.app }}
4444
needs: pre-job
45-
if: |
46-
${{
47-
(needs.pre-job.outputs.should_run_backend == 'false' && matrix.app == 'backend') ||
48-
(needs.pre-job.outputs.should_run_frontend == 'false' && matrix.app == 'frontend')
49-
}} && ${{ !github.event.pull_request.head.repo.fork }}
45+
if: ${{ !github.event.pull_request.head.repo.fork }}
5046
runs-on: ubuntu-latest
5147
strategy:
5248
matrix:
@@ -58,13 +54,25 @@ jobs:
5854
- app: frontend
5955
repository: wizarr-frontend
6056
steps:
57+
- name: Check if we should run for this app
58+
id: check_run
59+
run: |
60+
if [[ (${{ needs.pre-job.outputs.should_run_backend }} == 'false' && "${{ matrix.app }}" == "backend") || (${{ needs.pre-job.outputs.should_run_frontend }} == 'false' && "${{ matrix.app }}" == "frontend") ]]; then
61+
echo "should_run=true" >> $GITHUB_OUTPUT
62+
else
63+
echo "should_run=false" >> $GITHUB_OUTPUT
64+
fi
65+
6166
- name: Login to GitHub Container Registry
67+
if: steps.check_run.outputs.should_run == 'true'
6268
uses: docker/login-action@v3
6369
with:
6470
registry: ghcr.io
6571
username: ${{ github.repository_owner }}
6672
password: ${{ secrets.GITHUB_TOKEN }}
73+
6774
- name: Re-tag image
75+
if: steps.check_run.outputs.should_run == 'true'
6876
run: |
6977
REGISTRY_NAME="ghcr.io"
7078
REPOSITORY=${{ github.repository_owner }}/${{ matrix.repository }}
@@ -76,11 +84,6 @@ jobs:
7684
name: Build and Push ${{ matrix.app }}
7785
runs-on: ubuntu-latest
7886
needs: pre-job
79-
if: |
80-
${{
81-
(needs.pre-job.outputs.should_run_backend == 'true' && matrix.app == 'backend') ||
82-
(needs.pre-job.outputs.should_run_frontend == 'true' && matrix.app == 'frontend')
83-
}}
8487
strategy:
8588
fail-fast: false
8689
matrix:
@@ -99,31 +102,44 @@ jobs:
99102
env:
100103
context: .
101104
steps:
105+
- name: Check if we should run for this app
106+
id: check_run
107+
run: |
108+
if [[ (${{ needs.pre-job.outputs.should_run_backend }} == 'true' && "${{ matrix.app }}" == "backend") || (${{ needs.pre-job.outputs.should_run_frontend }} == 'true' && "${{ matrix.app }}" == "frontend") ]]; then
109+
echo "should_run=true" >> $GITHUB_OUTPUT
110+
else
111+
echo "should_run=false" >> $GITHUB_OUTPUT
112+
fi
113+
102114
- name: Checkout
115+
if: steps.check_run.outputs.should_run == 'true'
103116
uses: actions/checkout@v4
104117

105118
- name: Set up QEMU
119+
if: steps.check_run.outputs.should_run == 'true'
106120
uses: docker/setup-qemu-action@v3.2.0
107121

108122
- name: Set up Docker Buildx
123+
if: steps.check_run.outputs.should_run == 'true'
109124
uses: docker/setup-buildx-action@v3.8.0
110125

111126
- name: Login to Docker Hub
112-
if: ${{ github.event_name == 'release' }}
127+
if: steps.check_run.outputs.should_run == 'true' && github.event_name == 'release'
113128
uses: docker/login-action@v3
114129
with:
115130
username: ${{ secrets.DOCKERHUB_USERNAME }}
116131
password: ${{ secrets.DOCKERHUB_TOKEN }}
117132

118133
- name: Login to GitHub Container Registry
119-
if: ${{ !github.event.pull_request.head.repo.fork }}
134+
if: steps.check_run.outputs.should_run == 'true' && !github.event.pull_request.head.repo.fork
120135
uses: docker/login-action@v3
121136
with:
122137
registry: ghcr.io
123138
username: ${{ github.repository_owner }}
124139
password: ${{ secrets.GITHUB_TOKEN }}
125140

126141
- name: Generate docker image tags
142+
if: steps.check_run.outputs.should_run == 'true'
127143
id: metadata
128144
uses: docker/metadata-action@v5
129145
with:
@@ -138,6 +154,7 @@ jobs:
138154
type=raw,value=release,enable=${{ github.event_name == 'release' }}
139155
140156
- name: Determine build cache output
157+
if: steps.check_run.outputs.should_run == 'true'
141158
id: cache-target
142159
run: |
143160
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
@@ -147,6 +164,7 @@ jobs:
147164
fi
148165
149166
- name: Build and push image
167+
if: steps.check_run.outputs.should_run == 'true'
150168
uses: docker/build-push-action@v6.10.0
151169
with:
152170
context: ${{ env.context }}

0 commit comments

Comments
 (0)