From 77109c16925c473ef955f60800a620aee316addb Mon Sep 17 00:00:00 2001 From: texm Date: Tue, 25 Apr 2023 15:08:04 +0800 Subject: [PATCH] update workflow --- .github/workflows/publish.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d85ec03..ba33499 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,12 +1,11 @@ -name: Build & Publish Image +name: Create Release & Publish Image on: - release: - types: [published] - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + push: + branches: + - 'main' + tags: + - 'v*' jobs: build: @@ -16,7 +15,7 @@ jobs: packages: write steps: - - name: Checkout repository + - name: Checkout uses: actions/checkout@v3 - name: Log in to the Container registry @@ -26,16 +25,19 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata for Docker + - name: Extract Docker metadata id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + uses: docker/metadata-action@v4 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ghcr.io/texm/shokku + tags: | + type=ref,event=branch + type=semver,pattern={{raw}} - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file