|
| 1 | +# publish manually |
| 2 | +# ref : https://github.com/cicirello/pyaction/ |
| 3 | + |
| 4 | +name: Docker Publish Manual |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-push: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Prepare |
| 18 | + id: prep |
| 19 | + run: | |
| 20 | + DOCKERHUB_IMAGE=${{ vars.DOCKER_USERNAME }}/${{ github.event.repository.name }} |
| 21 | + GHCR_IMAGE=ghcr.io/${{ github.repository }} |
| 22 | + LATESTTAG=$(git describe --abbrev=0 --tags) |
| 23 | + VERSION=${LATESTTAG#v} |
| 24 | + MINOR=${VERSION%.*} |
| 25 | + MAJOR=${VERSION%%.*} |
| 26 | + TAGS="${DOCKERHUB_IMAGE}:${MAJOR},${DOCKERHUB_IMAGE}:${MINOR}" |
| 27 | + TAGS="${TAGS},${DOCKERHUB_IMAGE}:${VERSION},${DOCKERHUB_IMAGE}:latest" |
| 28 | + TAGS="${TAGS},${GHCR_IMAGE}:${MAJOR},${GHCR_IMAGE}:${MINOR}" |
| 29 | + TAGS="${TAGS},${GHCR_IMAGE}:${VERSION},${GHCR_IMAGE}:latest" |
| 30 | + echo "tags=${TAGS}" >> $GITHUB_OUTPUT |
| 31 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 32 | + echo "dockerhub_image=${DOCKERHUB_IMAGE}" >> $GITHUB_OUTPUT |
| 33 | + echo "ghcr_image=${GHCR_IMAGE}" >> $GITHUB_OUTPUT |
| 34 | +
|
| 35 | + - name: Set up QEMU |
| 36 | + uses: docker/setup-qemu-action@v3 |
| 37 | + with: |
| 38 | + platforms: all |
| 39 | + |
| 40 | + - name: Set up Docker Buildx |
| 41 | + id: buildx |
| 42 | + uses: docker/setup-buildx-action@v3 |
| 43 | + |
| 44 | + - name: Login to DockerHub |
| 45 | + uses: docker/login-action@v3 |
| 46 | + with: |
| 47 | + username: ${{ vars.DOCKER_USERNAME }} |
| 48 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 49 | + |
| 50 | + - name: Login to Github Container Registry |
| 51 | + uses: docker/login-action@v3 |
| 52 | + with: |
| 53 | + registry: ghcr.io |
| 54 | + username: ${{ github.repository_owner }} |
| 55 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + - name: Build and push |
| 58 | + uses: docker/build-push-action@v6 |
| 59 | + with: |
| 60 | + builder: ${{ steps.buildx.outputs.name }} |
| 61 | + context: . |
| 62 | + file: ./Dockerfile |
| 63 | + platforms: linux/amd64,linux/arm64 |
| 64 | + push: true |
| 65 | + tags: ${{ steps.prep.outputs.tags }} |
| 66 | + labels: org.opencontainers.image.version=${{ steps.prep.outputs.version }} |
0 commit comments