Merge pull request #269 from MyParcelCOM/develop #107
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: CI | |
on: push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: github.ref_name == 'develop' || github.ref_name == 'master' || github.ref_type == 'tag' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_PUBLIC_REPO_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_PUBLIC_REPO_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
mask-aws-account-id: 'true' | |
- name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@v2 | |
with: | |
mask-password: 'true' | |
- name: Prepare lowercase repository name | |
run: echo "REPOSITORY=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV" | |
- name: Prepare unique image tag | |
run: | | |
IMAGE_TAG=$GITHUB_REF_NAME | |
[[ $GITHUB_REF_TYPE == 'branch' ]] && IMAGE_TAG="${IMAGE_TAG}-${GITHUB_SHA:0:7}-$(date +'%s')" | |
echo "IMAGE_TAG=${IMAGE_TAG}" >> "$GITHUB_ENV" | |
- name: Build, tag, and push docker image to Amazon ECR | |
env: | |
REGISTRY: ${{ secrets.ECR_REGISTRY }} | |
REPOSITORY: ${{ env.REPOSITORY }} | |
IMAGE_TAG: ${{ env.IMAGE_TAG }} | |
run: | | |
docker build \ | |
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG \ | |
-f docker/build/Dockerfile . | |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG |