From f075a85ef24ee1fedef90a3b4811731a5d75a7d3 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 12 Oct 2021 15:48:56 -0700 Subject: [PATCH 1/2] [skip changelog] Correct context key name in "Sync Labels" workflow Incorrect context key name resulted in impossible to satisfy conditional, meaning the dry run determination code was solely dependent on the check for whether the workflow was triggered from the default branch name. --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index d6252692ad4..7a3f824d3d0 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -92,7 +92,7 @@ jobs: - name: Determine whether to dry run id: dry-run if: > - github.event == 'pull_request' || + github.event_name == 'pull_request' || github.ref != format('refs/heads/{0}', github.event.repository.default_branch) run: | # Use of this flag in the github-label-sync command will cause it to only check the validity of the From 38b9379b6d30cecab3c9f35b9f5587ad72dc6375 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 12 Oct 2021 15:49:18 -0700 Subject: [PATCH 2/2] [skip changelog] Sync labels in write mode on schedule trigger In order to facilitate the testing and review of proposed changes to the repository label infrastructure, the "Sync Labels" template workflow does a dry run when triggered under conditions that indicate it would not be appropriate to make real changes to the repository's labels. The changes that would have resulted are printed to the log, but not actually made. One of the criteria used to determine "dry run" mode usage is whether the event occurred on the repository's default branch. A trigger on a development branch or for a pull request should not result in a change to the labels. It turns out that GitHub does not define a `github.event.repository.default_branch` context item when a workflow is triggered by a `schedule` event. This resulted in the workflow always running in "dry run" mode on a `schedule` trigger. Since `schedule` and `repository_dispatch` triggers are only permitted for the default branch, there is no need to check whether the event's ref matches the default branch and it is safe to always run in write mode on these events. --- .github/workflows/sync-labels.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 7a3f824d3d0..f4c245eaf3c 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -93,7 +93,13 @@ jobs: id: dry-run if: > github.event_name == 'pull_request' || - github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + ( + ( + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' + ) && + github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + ) run: | # Use of this flag in the github-label-sync command will cause it to only check the validity of the # configuration.