Skip to content

Commit

Permalink
add env for username and add permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dletta committed Dec 23, 2024
1 parent 67ff722 commit da3fef5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
build:
runs-on: ubuntu-latest
name: 'Build container and push'
permissions:
packages: write
contents: read
steps:
- name: Checkout code
uses: actions/[email protected]
Expand All @@ -24,20 +27,22 @@ jobs:
id: checkdocker
shell: bash
run: |
if [ "$SECRET" == "" ]; then
if [ "$SECRET" == "" ] || [ "$USERNAME" == "" ]; then
echo "secretspresent=false" >> $GITHUB_OUTPUT
else
echo "secretspresent=true" >> $GITHUB_OUTPUT
fi
env:
SECRET: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}

- name: Set up Docker Buildx
if: ${{ steps.checkdocker.outputs.secretspresent }}
uses: docker/[email protected]

- name: Login to DockerHub
uses: docker/login-action@v3
if: ${{ steps.checkdocker.outputs.secretspresent == 'true' }}
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down

0 comments on commit da3fef5

Please sign in to comment.