forked from AcalaNetwork/subway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e524bba
commit 5640e8f
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |