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.
A0-3747: Create building process for subway application (#4)
- Loading branch information
1 parent
9c865c9
commit 73e3d28
Showing
2 changed files
with
93 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,33 @@ | ||
--- | ||
# This workflow checks if vars and secrets are present and fails if one is empty. | ||
# It should be included as a first step in all the workflows. | ||
name: Check vars and secrets | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
main: | ||
name: Check available vars and secrets | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check vars | ||
run: | | ||
if [[ \ | ||
-z '${{ vars.ECR_PUBLIC_HOST }}' || \ | ||
-z '${{ vars.ECR_PUBLIC_REGISTRY }}' | ||
]]; then | ||
echo '!!! Some repository variables are either missing or empty.' | ||
echo '!!! Please check either repository or organization settings.' | ||
exit 1 | ||
fi | ||
- name: Check secrets | ||
run: | | ||
if [[ \ | ||
-z '${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }}' || \ | ||
-z '${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }}' | ||
]]; then | ||
echo '!!! Some repository secrets are either missing or empty.' | ||
echo '!!! Please check either repository or organization settings.' | ||
exit 1 | ||
fi |
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,60 @@ | ||
--- | ||
name: Build subway docker image and push to ECR. | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- alephzero | ||
paths-ignore: | ||
- ".github/**" | ||
- "*.md" | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check-vars-and-secrets: | ||
name: Check vars and secrets | ||
uses: ./.github/workflows/_check-vars-and-secrets.yml | ||
secrets: inherit | ||
|
||
build-and-push-subway: | ||
name: Build and push subway image | ||
needs: [check-vars-and-secrets] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: GIT | Checkout Source code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Call action get-ref-properties | ||
id: get-ref-properties | ||
uses: Cardinal-Cryptography/github-actions/get-ref-properties@v6 | ||
|
||
- name: Get subway image name | ||
id: get-image-name | ||
env: | ||
ECR_REGISTRY: '${{ vars.ECR_PUBLIC_REGISTRY }}' | ||
APP: subway | ||
TAG: '${{ steps.get-ref-properties.outputs.sha }}' | ||
shell: bash | ||
run: | | ||
image=${{ env.ECR_REGISTRY }}${{ env.APP }}:${{ env.TAG }} | ||
echo "image=${image}" >> $GITHUB_OUTPUT | ||
- name: Build docker image | ||
run: | | ||
docker build --tag '${{ steps.get-image-name.outputs.image }}' -f ./Dockerfile . | ||
- name: Login to ECR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ vars.ECR_PUBLIC_HOST }} | ||
username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} | ||
password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} | ||
|
||
- name: Push image to the ECR registry | ||
id: push-image | ||
run: | | ||
docker push '${{ steps.get-image-name.outputs.image }}' |