Merge pull request #42 from iamyxsh/feature/sc3 #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Publish | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to publish (for example v0.1.0). Defaults to current ref." | |
| required: false | |
| type: string | |
| permissions: | |
| contents: read | |
| jobs: | |
| docker-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check publish secrets | |
| id: check-secrets | |
| run: | | |
| if [ -n "${DOCKERHUB_USERNAME}" ] && [ -n "${DOCKERHUB_TOKEN}" ]; then | |
| echo "publish_enabled=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "publish_enabled=false" >> "$GITHUB_OUTPUT" | |
| echo "::warning::Docker Hub credentials not configured — skipping publish." | |
| fi | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Checkout | |
| if: steps.check-secrets.outputs.publish_enabled == 'true' | |
| uses: actions/checkout@v4 | |
| - name: Resolve version | |
| if: steps.check-secrets.outputs.publish_enabled == 'true' | |
| id: meta | |
| shell: bash | |
| env: | |
| INPUT_TAG: ${{ github.event.inputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| if [ -n "${INPUT_TAG:-}" ]; then | |
| tag="${INPUT_TAG}" | |
| else | |
| tag="${GITHUB_REF_NAME}" | |
| fi | |
| case "${tag}" in | |
| v*) ;; | |
| *) | |
| echo "Tag must start with 'v' (got: ${tag})" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| version="${tag#v}" | |
| echo "tag=${tag}" >> "$GITHUB_OUTPUT" | |
| echo "version=${version}" >> "$GITHUB_OUTPUT" | |
| - name: Setup QEMU | |
| if: steps.check-secrets.outputs.publish_enabled == 'true' | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Setup Docker Buildx | |
| if: steps.check-secrets.outputs.publish_enabled == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: steps.check-secrets.outputs.publish_enabled == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push image | |
| if: steps.check-secrets.outputs.publish_enabled == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: | | |
| d3vdhruv/fishnet:${{ steps.meta.outputs.version }} | |
| d3vdhruv/fishnet:latest |