Skip to content

Commit 984f7ce

Browse files
authored
fix: update BUILD condition in pr-deploy.yaml (#9064)
This makes the build condition more understandable and fixes an issue where we could not deploy a new PR as the build condition was constantly evaluating false.
1 parent 6af6e85 commit 984f7ce

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

.github/workflows/pr-deploy.yaml

+7-18
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,7 @@ jobs:
7373
CODER_BASE_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
7474
CODER_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
7575
NEW: ${{ steps.check_deployment.outputs.NEW }}
76-
BUILD: |
77-
${{
78-
(steps.filter.outputs.all_count > steps.filter.outputs.ignored_count) &&
79-
(
80-
(github.event_name == 'push' && steps.check_deployment.outputs.NEW == 'false') ||
81-
github.event.inputs.build == 'true'
82-
)
83-
}}
76+
BUILD: ${{ steps.build_conditionals.outputs.first_or_force_build || steps.build_conditionals.outputs.automatic_rebuild }}
8477

8578
runs-on: "ubuntu-latest"
8679
steps:
@@ -162,18 +155,14 @@ jobs:
162155
echo "Total number of changed files: ${{ steps.filter.outputs.all_count }}"
163156
echo "Number of ignored files: ${{ steps.filter.outputs.ignored_count }}"
164157
165-
- name: Print job outputs
158+
- name: Build conditionals
159+
id: build_conditionals
166160
run: |
167161
set -euo pipefail
168-
# Print all outputs of this job
169-
echo "PR_NUMBER=${{ steps.pr_info.outputs.PR_NUMBER }}"
170-
echo "PR_TITLE=${{ steps.pr_info.outputs.PR_TITLE }}"
171-
echo "PR_URL=${{ steps.pr_info.outputs.PR_URL }}"
172-
echo "CODER_BASE_IMAGE_TAG=${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}"
173-
echo "CODER_IMAGE_TAG=${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}"
174-
echo "NEW=${{ steps.check_deployment.outputs.NEW }}"
175-
echo "BUILD=${{ (steps.filter.outputs.all_count > steps.filter.outputs.ignored_count) && ((github.event_name == 'push' && steps.check_deployment.outputs.NEW == 'false') || github.event.inputs.build == 'true') }}"
176-
echo "GITHUB_REF=${{ github.ref }}"
162+
# build if the workflow is manually triggered and the deployment doesn't exist (first build or force rebuild)
163+
echo "first_or_force_build=${{ (github.event_name == 'workflow_dispatch' && steps.check_deployment.outputs.NEW == 'true') || github.event.inputs.build == 'true' }}" >> $GITHUB_OUTPUT
164+
# build if the deployment alreday exist and there are changes in the files that we care about (automatic updates)
165+
echo "automatic_rebuild=${{ steps.check_deployment.outputs.NEW == 'false' && steps.filter.outputs.all_count > steps.filter.outputs.ignored_count }}" >> $GITHUB_OUTPUT
177166
178167
comment-pr:
179168
needs: [check_pr, get_info]

0 commit comments

Comments
 (0)