Skip to content

Commit

Permalink
Add condition on "deploy" step to only trigger on forks
Browse files Browse the repository at this point in the history
see DISCLAIMER comment
add required secrets in comment
  • Loading branch information
ctmbl committed Apr 14, 2024
1 parent 18397c7 commit 7d1b42a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,23 @@ jobs:
path: ./build/blog

# Deployment job: heavily inspired from https://swharden.com/blog/2022-03-20-github-actions-hugo/
# /!\ only triggers on push events
# /!\ only triggers on push events AND non-fork repos
## Required secrets:
# - SSH_KNOWN_HOSTS
# - PRIVATE_SSH_KEY
# - CI_USER_NAME
# - STATIC_WEBSITE_PATH
deploy:
needs: [build]
if: ${{ github.event_name == 'push' }}
# DISCLAIMER:
# The following is a very POOR solution to avoid *failing deploy step* due to missing secrets
# on fork repositories, but sadly the `env` context is not accessible from `jobs.<job_id>.if`:
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
#
# If for any reason you want to trigger this step on your fork remove the following line or
# open an issue https://github.com/iScsc/blog.iscsc.fr/issues, we'll find a better way to skip
# this step.
if: ${{ github.event_name == 'push' && github.event.repository.fork == 'false' }}
runs-on: ubuntu-latest
steps:
- name: 🛠️ Setup build directory
Expand Down

0 comments on commit 7d1b42a

Please sign in to comment.