diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index bfa8b56..ce47a77 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,23 +1,44 @@ name: Docker Image CI -on: - release: - types: [published] +on: push jobs: - build: + build: + name: Build new docker image + if: startsWith(github.event.ref, 'refs/tags/v') runs-on: ubuntu-latest + permissions: + packages: write steps: - - name: Checkout repo - uses: actions/checkout@v2 - - name: build and push - uses: docker/build-push-action@v1 - with: - registry: ghcr.io - username: "vforwater" - password: ${{ secrets.PAT }} - repository: vforwater/tbr_template_r - tags: latest,${{ github.ref_name }} + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to ghcr.io + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/vforwater/tool_template_r + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}