From d67ae71e4bca552f1963a62820003526af2d97e8 Mon Sep 17 00:00:00 2001 From: florianvazelle Date: Wed, 25 Oct 2023 20:19:36 +0200 Subject: [PATCH] ci: deploy only on the main branch --- .github/workflows/build.yml | 8 ++++---- .github/workflows/publish.yml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c83020e..1b0190f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: env: - tag_name: ${{ github.ref_name }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} jobs: build: @@ -43,7 +43,7 @@ jobs: - name: Ensure version is equal to tag if: startsWith(github.ref, 'refs/tags/') run: | - [ "${{ env.game_version }}" == "${{ env.tag_name }}" ] || exit 2 + [ "${{ env.game_version }}" == "${{ env.BRANCH_NAME }}" ] || exit 2 - name: Export Marble uses: ./.github/actions/export-game @@ -62,12 +62,12 @@ jobs: # Installing rsync is needed in order to deploy to GitHub Pages. Without it, the build will fail. - name: Install rsync - if: ${{ matrix.platform == 'web' }} + if: ${{ (matrix.platform == 'web') && (env.BRANCH_NAME == 'main') }} run: | apt-get update && apt-get install -y rsync - name: Deploy to GitHub Pages - if: ${{ matrix.platform == 'web' }} + if: ${{ (matrix.platform == 'web') && (env.BRANCH_NAME == 'main') }} uses: JamesIves/github-pages-deploy-action@v4 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c86529c..21cc3ac 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,7 @@ on: types: [completed] env: - head_branch: ${{ github.event.workflow_run.head_branch }} + BRANCH_NAME: ${{ github.event.workflow_run.head_branch }} jobs: set_tag_name: @@ -18,8 +18,8 @@ jobs: steps: - name: Check Tag run: | - if [[ ${{ env.head_branch }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "tag_name=${{ env.head_branch }}" >> "$GITHUB_ENV" + if [[ ${{ env.BRANCH_NAME }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "tag_name=${{ env.BRANCH_NAME }}" >> "$GITHUB_ENV" else echo "tag_name=null" >> "$GITHUB_ENV" fi