Skip to content

Commit

Permalink
Add new tag Github action (safe-global#525)
Browse files Browse the repository at this point in the history
* Add new github action

* Trigger action only on tag created event

* Upgrade metadata action, extract variables

* Trigger action on release event

* Trigger action only on release
  • Loading branch information
hectorgomezv authored Jul 3, 2023
1 parent 95e1d8e commit 98d8855
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI
on:
push:
pull_request:
release:
types: [ released ]

jobs:
prettier:
Expand Down Expand Up @@ -77,7 +79,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

docker-publish:
docker-publish-staging:
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: [ prettier, es-lint, tests-finish ]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -108,9 +110,43 @@ jobs:
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_TAG }}
cache-to: type=inline

docker-publish-release:
if: (github.event_name == 'release' && github.event.action == 'released')
needs: [ prettier, es-lint, tests-finish ]
runs-on: ubuntu-latest
env:
IMAGE_CACHE_SOURCE: staging
IMAGE_REGISTRY: safeglobal
IMAGE_NAME: safe-client-gateway-nest
steps:
- uses: actions/checkout@v3
- run: |
BUILD_NUMBER=${{ github.sha }}
echo "BUILD_NUMBER=${BUILD_NUMBER::7}" >> "$GITHUB_ENV"
- uses: docker/[email protected]
with:
platforms: arm64
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BUILD_NUMBER=${{ env.BUILD_NUMBER }}
VERSION=${{ github.ref_name }}
tags: |
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_CACHE_SOURCE }}
cache-to: type=inline

autodeploy:
runs-on: ubuntu-latest
needs: [ docker-publish ]
needs: [ docker-publish-staging ]
steps:
- uses: actions/checkout@v3
- name: Deploy Staging
Expand Down

0 comments on commit 98d8855

Please sign in to comment.