From cfbcf72135aba2abcc9cabff435c552b8eb32fe1 Mon Sep 17 00:00:00 2001 From: Yongun Seong Date: Sat, 24 Aug 2024 22:31:12 +0900 Subject: [PATCH] feat(ci): simplify image tag --- .github/workflows/build.yaml | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b949630..3dbb95d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,6 +4,8 @@ on: push: branches: - master + tags: + - v* permissions: contents: read @@ -13,26 +15,10 @@ permissions: jobs: build: runs-on: ubuntu-latest - outputs: - tag: ${{ steps.vars.outputs.image-tag }} - application: ${{ steps.vars.outputs.application }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Set variables - id: vars - env: - EVENT_NAME: ${{ github.event_name }} - REF_TYPE: ${{ github.ref_type }} - REF_NAME: ${{ github.ref_name }} - GIT_SHA: ${{ github.sha }} - run: | - date="$(date -u +%Y%m%d)" - short_rev="$(git rev-parse --short "$GIT_SHA")" - echo "image-tag=${REF_NAME}" >> $GITHUB_OUTPUT - echo "application=bacchus-snu/snucse-api" >> $GITHUB_OUTPUT - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Configure registry credentials @@ -41,11 +27,18 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set variables + uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/bacchus-snu/${{ vars.IMAGE_NAME }} - name: Build and push uses: docker/build-push-action@v4 with: context: . push: ${{ github.event_name != 'pull_request' }} - tags: ghcr.io/bacchus-snu/${{ vars.IMAGE_NAME }}:${{ steps.vars.outputs.image-tag }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max