-
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.
PM-1118: gha build workflow + dockerfile
- Loading branch information
Showing
2 changed files
with
71 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,62 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
inputs: | ||
docker_tag_prefix: | ||
description: "Enter the Docker Tag Prefix (e.g adhoc-test)" | ||
required: true | ||
type: string | ||
env: | ||
ECR_REPOSITORY_URL: 673156464838.dkr.ecr.us-west-2.amazonaws.com | ||
ECR_REPOSITORY_NAME: mina-transactions-generator | ||
DOCKER_TAG_PREFIX: ${{ github.event.inputs.docker_tag_prefix }} | ||
|
||
# This allows a subsequently queued workflow run to interrupt previous runs | ||
concurrency: | ||
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}' | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-docker-image: | ||
name: Build and Push Docker Image | ||
runs-on: minafoundation-default-runners | ||
steps: | ||
- name: π₯ Checkout | ||
uses: actions/checkout@v3 | ||
- name: π·οΈ Generate Tag | ||
run: | | ||
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | ||
PREFIX=${{ env.DOCKER_TAG_PREFIX }} | ||
elif [ "${{ github.event_name }}" == "push" ] && [ -n "${{ github.event.ref }}" ]; then | ||
PREFIX=$(basename ${{ github.ref }}) | ||
else | ||
echo "Invalid event. Exiting..." | ||
exit 1 | ||
fi | ||
echo "TAG=$PREFIX-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV | ||
- name: π ECR Login | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
- name: π Check if Tag already exists | ||
id: checktag | ||
uses: tyriis/docker-image-tag-exists@main | ||
with: | ||
registry: ${{ env.ECR_REPOSITORY_URL}} | ||
repository: ${{ env.ECR_REPOSITORY_NAME }} | ||
tag: ${{ env.TAG }} | ||
- name: ποΈ Install Dependencies | ||
run: | | ||
npm install | ||
- name: π¦ Compile Mina Transactions Generator | ||
run: | | ||
npm run build | ||
- name: π οΈ Build Mina Transactions Generator Docker Image | ||
if: steps.checktag.outputs.tag == 'not found' | ||
run: DOCKER_BUILDKIT=1 docker build -t ${{ env.ECR_REPOSITORY_URL}}/${{ env.ECR_REPOSITORY_NAME }}:${{ env.TAG }} . | ||
- name: π Push Mina Transactions Generator Docker Image | ||
if: steps.checktag.outputs.tag == 'not found' | ||
run: docker push ${{ env.ECR_REPOSITORY_URL}}/${{ env.ECR_REPOSITORY_NAME }}:${{ env.TAG }} |
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,9 @@ | ||
FROM node:alpine | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package*.json ./ | ||
|
||
COPY ./build ./ | ||
|
||
CMD ["node", "./src/entry.js"] |