This repository has been archived by the owner on Dec 13, 2024. It is now read-only.
Merge pull request #4 from co-cddo/refactor-zendesk-backup #6
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: 'Lambda GOV.UK Reference Content Crawler Deploy' | |
on: | |
push: | |
branches: [ "main" ] | |
paths: | |
- lambda_/crawler-govuk-reference-content/** | |
- .github/workflows/lambda_crawler-govuk-reference-content_deploy.yml | |
workflow_dispatch: | |
env: | |
# Setting an environment variable with the value of a configuration variable | |
AWS_REGION: ${{ vars.AWS_REGION }} | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
max-parallel: 1 | |
fail-fast: true | |
matrix: | |
include: | |
- environment: staging | |
- environment: production | |
environment: | |
name: ${{ matrix.environment }} | |
steps: | |
# Checkout the repository to the GitHub Actions runner | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Build ZIP file | |
run: | | |
echo "github.ref: ${{ github.ref }}" | |
ls -lah | |
bash build.sh | |
working-directory: lambda_/crawler-govuk-reference-content/ | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-session-name: ${{ github.run_id }}-${{ github.event_name }}-${{ github.job }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Test AWS access | |
run: | | |
aws sts get-caller-identity | |
ls -lah | |
working-directory: lambda_/crawler-govuk-reference-content/ | |
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. | |
- name: Terraform Init | |
run: terraform init | |
working-directory: lambda_/crawler-govuk-reference-content/ | |
# Checks that all Terraform configuration files adhere to a canonical format | |
- name: Terraform Format | |
run: terraform fmt -check | |
working-directory: lambda_/crawler-govuk-reference-content/ | |
# Generates an execution plan for Terraform | |
- name: Terraform Apply | |
run: | | |
terraform workspace select $TERRAFORM_WORKSPACE | |
terraform apply -auto-approve \ | |
-input=false \ | |
-var="staging_iam_role=${{ secrets.STAGING_IAM_ROLE }}" \ | |
-var="production_iam_role=${{ secrets.PRODUCTION_IAM_ROLE }}" | |
env: | |
TERRAFORM_WORKSPACE: ${{ matrix.environment }} | |
working-directory: lambda_/crawler-govuk-reference-content/ |