Skip to content

Fix message input param #13

Fix message input param

Fix message input param #13

Workflow file for this run

name: Push Image Workflow
on:
create:
push:
branches:
- release/**
- develop
paths-ignore:
- "*.md"
env:
AWS_REGION: eu-west-2
node-version: 18.x
ECR_REPO_NAME: gap-lambda-update-open-search
jobs:
build:
runs-on: ubuntu-latest
# Need to check here as create event can't be filtered by branch name...
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/release')
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- run: npm install
imageBuild:
needs: build
permissions:
id-token: write
contents: read
environment: AWS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Fetch all commits since we use the total commit count to determine the build version
fetch-depth: 0
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: ${{ env.ECR_REPO_NAME }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Determine & set BUILD_VERSION
run: |
GIT_COUNT=$(git rev-list $GITHUB_SHA --count)
echo "BUILD_VERSION=b_$GIT_COUNT" >> $GITHUB_ENV
echo BUILD_VERSION is ${{ env.BUILD_VERSION }}
- run: npm install
- name: Build, tag and push Docker image to AWS ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build --tag $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:${{ env.BUILD_VERSION }} .
docker push $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:${{ env.BUILD_VERSION }}
- name: Create env tag
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
ENV_TAG=${{ (github.ref == 'refs/heads/develop' && 'develop') || (startsWith(github.ref, 'refs/heads/release') && 'qa') }}
docker tag $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:${{ env.BUILD_VERSION }} $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:$ENV_TAG
docker push $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:$ENV_TAG
- name: Create release tag - if we are committing to a release branch
if: ${{ startsWith(github.ref, 'refs/heads/release/') }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
RELEASE_VERSION=V_${GITHUB_REF##*/}
docker tag $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:${{ env.BUILD_VERSION }} $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:$RELEASE_VERSION
docker push $ECR_REGISTRY/${{ env.ECR_REPO_NAME }}:$RELEASE_VERSION