[EPMRPP-80926] Replace UniqueID boosting field with Test Case Hash #2
Workflow file for this run
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
name: Build Docker image | |
on: | |
pull_request: | |
types: [submitted] | |
env: | |
AWS_REGION: ${{ vars.AWS_REGION }} # set this to your preferred AWS region, e.g. us-west-1 | |
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }} # set this to your Amazon ECR repository name | |
PLATFORMS: ${{ vars.BUILD_PLATFORMS }} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
environment: development | |
if: github.base_ref == 'develop' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set short git commit SHA | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Build and export | |
uses: docker/build-push-action@v4 | |
env: | |
VERSION: ${{ github.head_ref }}-${{ steps.vars.outputs.sha_short }} | |
BRANCH: ${{ github.head_ref }} | |
DATE: ${{ steps.date.outputs.date }} | |
with: | |
context: . | |
build-args: APP_VERSION=${{ env.VERSION }},BUILD_BRANCH=${{ env.BRANCH }},BUILD_DATE=${{ env.DATE }} | |
platforms: ${{ env.PLATFORMS }} | |
tags: ${{ github.repository }}:latest | |
outputs: type=docker,dest=/tmp/docker-image.tar | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-image | |
path: /tmp/docker-image.tar | |
push_to_ecr: | |
name: Push to Amazon ECR | |
needs: build | |
runs-on: ubuntu-latest | |
environment: development | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: docker-image | |
path: /tmp | |
- name: Load image | |
run: | | |
docker load --input /tmp/docker-image.tar | |
docker image ls -a | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
# role-to-assume: arn:aws:iam::123456789012:role/my-github-actions-role | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
with: | |
mask-password: 'true' | |
- name: Create image tag | |
id: image-tag | |
run: | | |
echo "tag=$(echo ${{ github.head_ref }}-${{ github.run_number }} | tr '/' '-')" >> $GITHUB_OUTPUT | |
- name: Tag and push docker image to Amazon ECR | |
id: push-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
IMAGE_TAG: ${{ steps.image-tag.outputs.tag }} | |
run: | | |
docker tag ${{ github.repository }} $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "## General information about the build:" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "- :gift: Docker image in Amazon ECR: $ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_STEP_SUMMARY | |
echo "- :octocat: The commit SHA from which the build was performed: [$GITHUB_SHA](https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY |