diff --git a/.github/workflows/publish-image.yaml b/.github/workflows/publish-image.yaml new file mode 100644 index 0000000..4836e5c --- /dev/null +++ b/.github/workflows/publish-image.yaml @@ -0,0 +1,40 @@ +name: Publish Image + +on: + push: + branches: ['master'] + tags: ['*'] + +env: + DOCKER_HUB_USER: phlak + +jobs: + build-and-push: + name: Build & Push + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ env.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Extract Metadata + id: extract-metadata + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_HUB_USER }}/directory-lister + tags: | + type=raw,value=latest + type=ref,event=tag + + - name: Build & Push Image + uses: docker/build-push-action@v6 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.extract-metadata.outputs.tags }} + labels: ${{ steps.extract-metadata.outputs.labels }}