Renovate Update Patch & Minor Updates #1205
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: Test & Build | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- name: Image cache | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/images | |
key: ${{ runner.os }}-images-${{ github.run_id }}-${{ github.run_number }} | |
- name: Build Images | |
run: make build | |
- name: Trivy Image Vulnerability Scanner | |
uses: aquasecurity/[email protected] | |
with: | |
image-ref: 311462405659.dkr.ecr.eu-west-1.amazonaws.com/integrations/lpa-uid-create-case-lambda:latest | |
severity: "HIGH,CRITICAL" | |
format: "sarif" | |
output: "trivy-results.sarif" | |
- name: Upload Trivy scan results to GitHub Security tab | |
id: trivy_upload_sarif | |
uses: github/codeql-action/upload-sarif@v3 | |
if: always() | |
with: | |
sarif_file: "trivy-results.sarif" | |
- name: Save Images | |
run: | | |
mkdir -p /tmp/images | |
docker save -o /tmp/images/lambda-create-case.tar 311462405659.dkr.ecr.eu-west-1.amazonaws.com/integrations/lpa-uid-create-case-lambda:latest | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 'stable' | |
- name: Run unit tests | |
run: make test | |
integration-test: | |
name: Integration test | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Image cache | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/images | |
key: ${{ runner.os }}-images-${{ github.run_id }}-${{ github.run_number }} | |
- name: Setup terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.4.6 | |
terraform_wrapper: false | |
- name: Restore Image | |
run: docker load -i /tmp/images/lambda-create-case.tar | |
- run: make up test-api | |
push: | |
name: Push images | |
needs: [test, integration-test] | |
runs-on: ubuntu-latest | |
outputs: | |
branch: ${{ steps.set-outputs.outputs.branch }} | |
tag: ${{ steps.bump_version.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- name: Extract branch name | |
run: | | |
if [ "$GITHUB_EVENT_NAME" == "push" ]; then | |
echo BRANCH_NAME=main >> $GITHUB_ENV | |
else | |
echo BRANCH_NAME=${{ github.head_ref }} >> $GITHUB_ENV | |
fi | |
id: extract_branch | |
- name: Bump version | |
id: bump_version | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
INITIAL_VERSION: 0.0.0 | |
DEFAULT_BRANCH: main | |
DEFAULT_BUMP: minor | |
PRERELEASE: true | |
PRERELEASE_SUFFIX: ${{ env.BRANCH_NAME }} | |
RELEASE_BRANCHES: main | |
WITH_V: true | |
- uses: unfor19/install-aws-cli-action@v1 | |
- name: Configure AWS Credentials | |
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: eu-west-1 | |
role-to-assume: arn:aws:iam::311462405659:role/integrations-ci | |
role-duration-seconds: 3600 | |
role-session-name: GitHubActions | |
- name: ECR Login | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
with: | |
registries: 311462405659 | |
- name: Image cache | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/images | |
key: ${{ runner.os }}-images-${{ github.run_id }}-${{ github.run_number }} | |
- name: Restore Image | |
run: docker load -i /tmp/images/lambda-create-case.tar | |
- name: Push Containers | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: integrations/lpa-uid-create-case-lambda | |
run: | | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:latest $ECR_REGISTRY/$ECR_REPOSITORY:${{ steps.bump_version.outputs.tag }} | |
if [ $BRANCH_NAME == "main" ]; then | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:latest $ECR_REGISTRY/$ECR_REPOSITORY:main | |
# We want all of the tags pushed | |
docker push --all-tags $ECR_REGISTRY/$ECR_REPOSITORY | |
else | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ steps.bump_version.outputs.tag }} | |
fi | |
echo "Container tag: ${{ steps.bump_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY | |
deploy-development: | |
name: Deploy to Development | |
needs: [push] | |
uses: ./.github/workflows/deploy.yml | |
with: | |
workspace_name: development | |
version_tag: ${{ needs.push.outputs.tag }} | |
secrets: | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
deploy-preproduction: | |
name: Deploy to Preproduction | |
needs: [push, deploy-development] | |
uses: ./.github/workflows/deploy.yml | |
with: | |
workspace_name: preproduction | |
version_tag: ${{ needs.push.outputs.tag }} | |
secrets: | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
deploy-production: | |
name: Deploy to Production | |
needs: [push, deploy-preproduction] | |
uses: ./.github/workflows/deploy.yml | |
with: | |
workspace_name: production | |
version_tag: ${{ needs.push.outputs.tag }} | |
secrets: | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |