Skip to content

Commit

Permalink
ci: deploy only on the main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Oct 25, 2023
1 parent 18cd64c commit d67ae71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:

env:
tag_name: ${{ github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
build:
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit d67ae71

Please sign in to comment.