Skip to content

Commit

Permalink
GHA: Attempt dockerhub upload only if secrets are accessible (#385)
Browse files Browse the repository at this point in the history
e.g., they won't be accessible during builds for dependabot PRs.
  • Loading branch information
dweindl committed Sep 16, 2024
1 parent d2c341f commit 1c9fd93
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/deploy_dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@
name: Deploy to dockerhub
on: [push, workflow_dispatch]
jobs:
check-secret:
runs-on: ubuntu-latest
outputs:
secrets-defined: ${{ steps.secret-check.outputs.defined }}
steps:
- name: Check for Secret availability
id: secret-check
shell: bash
run: |
if [ "${{ secrets.DOCKER_USERNAME }}" != '' ]; then
echo "defined=true" >> $GITHUB_OUTPUT;
else
echo "defined=false" >> $GITHUB_OUTPUT;
fi
build:
name: Deploy to dockerhub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- run: git archive -v -o container/charliecloud/parpe_base/parpe.tar.gz --format=tar.gz HEAD
- name: Publish to Registry
if: needs.check-secret.outputs.secrets-defined == 'true'
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: dweindl/parpe
Expand Down

0 comments on commit 1c9fd93

Please sign in to comment.