From dd4f4bdd3e68c98464ba61217b82d96c79ed1328 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Wed, 28 Jun 2023 11:01:27 +0200 Subject: [PATCH] Publish image for tags as well --- .github/workflows/publish.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8cdeaeb..03ac849 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,7 @@ on: paths-ignore: - '**/*.md' branches: [ main ] + tags: [ '*' ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -19,14 +20,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Login to GitHub Container Registry + + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: winglang password: ${{ secrets.GITHUB_TOKEN }} - - run: | + + - name: Build and push + run: | docker build -t wing-action . - docker tag wing-action ghcr.io/winglang/wing-github-action:main - docker push ghcr.io/winglang/wing-github-action:main \ No newline at end of file + + # For main branch, tag it as 'main' + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + docker tag wing-action ghcr.io/winglang/wing-github-action:main + docker push ghcr.io/winglang/wing-github-action:main + fi + + # For new tags, tag the docker image with the same tag + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + TAG=${GITHUB_REF#refs/tags/} + docker tag wing-action ghcr.io/winglang/wing-github-action:$TAG + docker push ghcr.io/winglang/wing-github-action:$TAG + fi