From bf338048f80d0c58660e12d15bf0299ad97bf5af Mon Sep 17 00:00:00 2001 From: xeniape Date: Thu, 13 Jun 2024 10:33:47 +0200 Subject: [PATCH 1/6] add workflow_dispatch and schedule event triggers --- template/.github/workflows/build.yml.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index def7500b..5aebef72 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -16,6 +16,9 @@ on: - '[0-9][0-9].[0-9]+.[0-9]+' pull_request: merge_group: + schedule: + - cron: '15 3 * * 6' + workflow_dispatch: env: CARGO_TERM_COLOR: always From 90195bfbe619f993f173032b383573033431e9dd Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 17 Jun 2024 15:43:52 +0200 Subject: [PATCH 2/6] update build template to include trigger checks --- template/.github/workflows/build.yml.j2 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 5aebef72..bb7136dd 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -16,6 +16,7 @@ on: - '[0-9][0-9].[0-9]+.[0-9]+' pull_request: merge_group: + # rebuild of main branch runs every saturday night schedule: - cron: '15 3 * * 6' workflow_dispatch: @@ -87,13 +88,13 @@ jobs: TRIGGER: ${{ github.event_name }} GITHUB_REF: ${{ github.ref }} run: | - if [[ $TRIGGER == "pull_request" ]]; then - echo "exporting test as target helm repo: ${{ env.TEST_REPO_HELM_URL }}" - echo "helm_repo=${{ env.TEST_REPO_HELM_URL }}" >> $GITHUB_OUTPUT - elif [[ $TRIGGER == "push" && $GITHUB_REF == "refs/heads/main" ]]; then + if [[ ( $TRIGGER == "push" || $TRIGGER == "schedule" || $TRIGGER == "workflow_dispatch" ) && $GITHUB_REF == "refs/heads/main" ]]; then echo "exporting dev as target helm repo: ${{ env.DEV_REPO_HELM_URL }}" echo "helm_repo=${{ env.DEV_REPO_HELM_URL }}" >> $GITHUB_OUTPUT - elif [[ ( $TRIGGER == "create" || $TRIGGER == "push" ) && $GITHUB_REF == refs/tags/* ]]; then + elif [[ $TRIGGER == "pull_request" || ( $TRIGGER == "workflow_dispatch" && $GITHUB_REF == refs/heads/* )]]; then + echo "exporting test as target helm repo: ${{ env.TEST_REPO_HELM_URL }}" + echo "helm_repo=${{ env.TEST_REPO_HELM_URL }}" >> $GITHUB_OUTPUT + elif [[ ( $TRIGGER == "push" ) && $GITHUB_REF == refs/tags/* ]]; then echo "exporting stable as target helm repo: ${{ env.STABLE_REPO_HELM_URL }}" echo "helm_repo=${{ env.STABLE_REPO_HELM_URL }}" >> $GITHUB_OUTPUT else @@ -345,6 +346,9 @@ jobs: - name: Update version if PR if: ${{ github.event_name == 'pull_request' }} run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} + - name: Update version if manual trigger on non-main branch + if: ${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }} + run: cargo set-version --offline --workspace branch-${{ github.ref_name }} # Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the # default value in the makefile if called from this action, but not otherwise (i.e. when called locally). From 0d4b8d70b57442a7fb28723412b794f2f5cd9609 Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 17 Jun 2024 15:53:51 +0200 Subject: [PATCH 3/6] update build template to include trigger checks --- template/.github/workflows/build.yml.j2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index bb7136dd..89b6cc5b 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -88,12 +88,12 @@ jobs: TRIGGER: ${{ github.event_name }} GITHUB_REF: ${{ github.ref }} run: | - if [[ ( $TRIGGER == "push" || $TRIGGER == "schedule" || $TRIGGER == "workflow_dispatch" ) && $GITHUB_REF == "refs/heads/main" ]]; then - echo "exporting dev as target helm repo: ${{ env.DEV_REPO_HELM_URL }}" - echo "helm_repo=${{ env.DEV_REPO_HELM_URL }}" >> $GITHUB_OUTPUT - elif [[ $TRIGGER == "pull_request" || ( $TRIGGER == "workflow_dispatch" && $GITHUB_REF == refs/heads/* )]]; then + if [[ $TRIGGER == "pull_request" || ( $TRIGGER == "workflow_dispatch" && $GITHUB_REF != refs/heads/main )]]; then echo "exporting test as target helm repo: ${{ env.TEST_REPO_HELM_URL }}" echo "helm_repo=${{ env.TEST_REPO_HELM_URL }}" >> $GITHUB_OUTPUT + elif [[ ( $TRIGGER == "push" || $TRIGGER == "schedule" || $TRIGGER == "workflow_dispatch" ) && $GITHUB_REF == "refs/heads/main" ]]; then + echo "exporting dev as target helm repo: ${{ env.DEV_REPO_HELM_URL }}" + echo "helm_repo=${{ env.DEV_REPO_HELM_URL }}" >> $GITHUB_OUTPUT elif [[ ( $TRIGGER == "push" ) && $GITHUB_REF == refs/tags/* ]]; then echo "exporting stable as target helm repo: ${{ env.STABLE_REPO_HELM_URL }}" echo "helm_repo=${{ env.STABLE_REPO_HELM_URL }}" >> $GITHUB_OUTPUT From 949debe1c35933cc0ecac158e906141fdb5a90bd Mon Sep 17 00:00:00 2001 From: xeniape Date: Tue, 18 Jun 2024 08:14:26 +0200 Subject: [PATCH 4/6] removed workflow_dispatch checks for non-main branches --- template/.github/workflows/build.yml.j2 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 89b6cc5b..476544d8 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -88,13 +88,13 @@ jobs: TRIGGER: ${{ github.event_name }} GITHUB_REF: ${{ github.ref }} run: | - if [[ $TRIGGER == "pull_request" || ( $TRIGGER == "workflow_dispatch" && $GITHUB_REF != refs/heads/main )]]; then + if [[ $TRIGGER == "pull_request" ]]; then echo "exporting test as target helm repo: ${{ env.TEST_REPO_HELM_URL }}" echo "helm_repo=${{ env.TEST_REPO_HELM_URL }}" >> $GITHUB_OUTPUT elif [[ ( $TRIGGER == "push" || $TRIGGER == "schedule" || $TRIGGER == "workflow_dispatch" ) && $GITHUB_REF == "refs/heads/main" ]]; then echo "exporting dev as target helm repo: ${{ env.DEV_REPO_HELM_URL }}" echo "helm_repo=${{ env.DEV_REPO_HELM_URL }}" >> $GITHUB_OUTPUT - elif [[ ( $TRIGGER == "push" ) && $GITHUB_REF == refs/tags/* ]]; then + elif [[ $TRIGGER == "push" && $GITHUB_REF == refs/tags/* ]]; then echo "exporting stable as target helm repo: ${{ env.STABLE_REPO_HELM_URL }}" echo "helm_repo=${{ env.STABLE_REPO_HELM_URL }}" >> $GITHUB_OUTPUT else @@ -346,9 +346,6 @@ jobs: - name: Update version if PR if: ${{ github.event_name == 'pull_request' }} run: cargo set-version --offline --workspace 0.0.0-pr${{ github.event.pull_request.number }} - - name: Update version if manual trigger on non-main branch - if: ${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }} - run: cargo set-version --offline --workspace branch-${{ github.ref_name }} # Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the # default value in the makefile if called from this action, but not otherwise (i.e. when called locally). From a71dea562c3ff5ae0622e6f2decd8018a7402881 Mon Sep 17 00:00:00 2001 From: Xenia Date: Tue, 18 Jun 2024 13:41:11 +0200 Subject: [PATCH 5/6] Update template/.github/workflows/build.yml.j2 Co-authored-by: Nick --- template/.github/workflows/build.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index 476544d8..e349d93d 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -16,8 +16,8 @@ on: - '[0-9][0-9].[0-9]+.[0-9]+' pull_request: merge_group: - # rebuild of main branch runs every saturday night schedule: + # Run every Saturday morning: https://crontab.guru/#15_3_*_*_6 - cron: '15 3 * * 6' workflow_dispatch: From 63ed92b3b2d68ba2b951c69cdef856fef74dc722 Mon Sep 17 00:00:00 2001 From: xeniape Date: Tue, 18 Jun 2024 14:23:42 +0200 Subject: [PATCH 6/6] update job comment to reflect the code behaviour --- template/.github/workflows/build.yml.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/template/.github/workflows/build.yml.j2 b/template/.github/workflows/build.yml.j2 index e349d93d..b9035581 100644 --- a/template/.github/workflows/build.yml.j2 +++ b/template/.github/workflows/build.yml.j2 @@ -68,11 +68,11 @@ jobs: # repository: test # # - all tagged releases land in stable: - # condition: github.event_name == 'create' & github.ref.startswith('refs/tags/') + # condition: github.event_name == 'push' & github.ref.startswith('refs/tags/') # repository: stable # - # - all pushes to main (i.e. PR-merges) land in dev: - # condition: github.event_name == 'push' & github.ref == 'refs/heads/main' + # - all pushes to main (i.e. PR-merges) and all scheduled/manual workflow runs on main land in dev: + # condition: ( github.event_name == 'push' | github.event_name == 'schedule' | github.event_name == 'workflow_dispatch' ) & github.ref == 'refs/heads/main' # repository: dev # # Any other scenarios (e.g. when a branch is created/pushed) will cause the publish step to be skipped, most commonly this is expected to happen for the