diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 6baeaf9..4a24df2 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -2,12 +2,25 @@ name: Integration Test on: pull_request: + push: + branches: + - main + tags: + - 'v*.*.*' + workflow_dispatch: + +env: + AWS_DEFAULT_REGION: us-east-1 jobs: - build: + test: runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -28,8 +41,58 @@ jobs: diff: pr.diff module: github.com/panagiotisptr/cov-diff - - name: Comment + - name: Comment on PR uses: mshick/add-pr-comment@v2 with: message: | Coverage on new code: ${{ steps.selftest.outputs.covdiff }}% + + build_push: + needs: test + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure AWS credentials + if: github.event_name != 'pull_request' + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + + - name: Login to Amazon ECR + if: github.event_name != 'pull_request' + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Determine ECR image tags + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ steps.login-ecr.outputs.registry && format('{0}/', steps.login-ecr.outputs.registry) || '' }}cov-diff + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + type=sha + type=semver,pattern=v{{version}},event=tag + + - name: Build and Push Docker image to ECR + id: build_and_push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha,scope=${{ github.workflow }} + cache-to: type=gha,mode=max,scope=${{ github.workflow }}