Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release tagging #24

Merged
merged 1 commit into from
May 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Tag branch version as release

on:
release:
types: [released]

jobs:
tag-release:
name: Tag branch version as release
runs-on: ubuntu-latest
steps:
- name: GIT | Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: GIT | Checkout Source code
uses: actions/checkout@v4
with:
submodules: recursive

- name: GIT | Get branch info & current commit sha.
id: vars
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

- name: Login to Public Amazon ECR
id: login-public-ecr
uses: docker/login-action@v1
with:
registry: ${{vars.ECR_PUBLIC_HOST}}
username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1

- name: Tag and push release image
env:
BASE_IMAGE: ${{ vars.ECR_PUBLIC_REGISTRY }}subway:${{ steps.vars.outputs.sha_short }}
RELEASE_IMAGE: ${{ vars.ECR_PUBLIC_REGISTRY }}subway:${{ steps.vars.outputs.branch }}
run: |
export image_not_exist=$(docker manifest inspect ${{ env.BASE_IMAGE }} &> /dev/null ; echo $?)

if [ $image_not_exist -eq 1 ]; then
echo "::error title=Wrong docker image tag::Docker image ${{ env.BASE_IMAGE }} doesn't exist"
exit 1
else
docker pull ${{ env.BASE_IMAGE }}
docker tag ${{ env.BASE_IMAGE }} ${{ env.RELEASE_IMAGE }}
docker push ${{ env.RELEASE_IMAGE }}
fi
Loading