diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d5eb29..e2ae483 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build and publish Container Image on: push: - branches: ["main"] + workflow_dispatch: env: REGISTRY: ghcr.io @@ -15,7 +15,7 @@ jobs: contents: read packages: write outputs: - imageTag: ${{ steps.meta.outputs.tags }} + deployImage: ${{ fromJSON(steps.meta.outputs.json).tags[0] }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -42,6 +42,11 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=sha + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=ref,event=branch + type=ref,event=pr - name: Build and push Docker image uses: docker/build-push-action@v5 @@ -59,9 +64,10 @@ jobs: runs-on: ubuntu-latest concurrency: deploy-group # ensure only one action runs at a time needs: build-and-push-image + if: github.event == 'push' && github.ref == 'refs/head/main' steps: - uses: actions/checkout@v4 - uses: superfly/flyctl-actions/setup-flyctl@1.5 - - run: flyctl deploy --image ${{ needs.build-and-push-image.outputs.imageTag }} + - run: flyctl deploy --image ${{ needs.build-and-push-image.outputs.deployImage }} env: FLY_API_TOKEN: ${{ secrets.FLY_DEPLOY_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index daa9276..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Release Container Image - -on: - push: - tags: ["*"] - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - publish-image: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}} - type=raw,value=latest - type=sha - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }}