From aab0175b19c90cc6b93f0bce9ff7ae9a704b00c3 Mon Sep 17 00:00:00 2001 From: raikbitters Date: Wed, 1 Nov 2023 17:10:48 +0400 Subject: [PATCH] Add github action for building dev images --- .github/workflows/build-dev-image.yml | 70 +++++++++++++++++++ .../{rc.yaml => build-rc-image.yaml} | 0 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/build-dev-image.yml rename .github/workflows/{rc.yaml => build-rc-image.yaml} (100%) diff --git a/.github/workflows/build-dev-image.yml b/.github/workflows/build-dev-image.yml new file mode 100644 index 00000000..c499c2ba --- /dev/null +++ b/.github/workflows/build-dev-image.yml @@ -0,0 +1,70 @@ +name: Build develop Docker image + +on: + push: + branches: + - develop + paths-ignore: + - '.github/**' + - README.md + +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 }} # set target build platforms. By default linux/amd64 + IMAGE_TAG: develop-${{ github.run_number }} # set the image tag + +jobs: + build-and-export: + name: Build and export to AWS ECR + runs-on: ubuntu-latest + environment: development + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + 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 variables + id: vars + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build + uses: docker/build-push-action@v4 + env: + VERSION: ${{ github.ref_name }}-${{ steps.vars.outputs.sha_short }} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + with: + context: . + push: true + build-args: | + APP_VERSION=${{ env.VERSION }} + platforms: ${{ env.PLATFORMS }} + tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + + - name: Summarize + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + echo "## General information about the build:" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- :gift: Docker image in Amazon ECR: 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 \ No newline at end of file diff --git a/.github/workflows/rc.yaml b/.github/workflows/build-rc-image.yaml similarity index 100% rename from .github/workflows/rc.yaml rename to .github/workflows/build-rc-image.yaml