Skip to content

Commit

Permalink
Add condition to deploy job to only trigger if required secrets are set
Browse files Browse the repository at this point in the history
  • Loading branch information
ctmbl committed Mar 5, 2024
1 parent 18397c7 commit 083b18b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ 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 on repos provinding required secrets
deploy:
needs: [build]
if: ${{ github.event_name == 'push' }}
## Required secrets:
# - SSH_KNOWN_HOSTS
# - PRIVATE_SSH_KEY
# - CI_USER_NAME
# - STATIC_WEBSITE_PATH
env:
HAVE_REQUIRED_SECRETS: ${{ secrets.SSH_KNOWN_HOSTS != '' && secrets.PRIVATE_SSH_KEY != '' && secrets.CI_USER_NAME != '' && secrets.STATIC_WEBSITE_PATH != '' }}
if: ${{ github.event_name == 'push' && env.HAVE_REQUIRED_SECRETS == 'true'}}
runs-on: ubuntu-latest
steps:
- name: 🛠️ Setup build directory
Expand Down

0 comments on commit 083b18b

Please sign in to comment.