Skip to content

How to run the deploy only on main branch? #630

Answered by peaceiris
simonppg asked this question in Q&A
Discussion options

You must be logged in to vote

The latest README mentions this already.

name: GitHub Pages

on:
  push:
    branches:
      - main  # Set a branch name to trigger deployment
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-20.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v2
...
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
+       if: ${{ github.ref == 'refs/heads/main' }}
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@peaceiris
Comment options

Answer selected by simonppg
Comment options

You must be logged in to vote
2 replies
@peaceiris
Comment options

@simonppg
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants