Merge branch 'main' into one-login #324
Workflow file for this run
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
--- | |
# ------------------------------------------------------------------------------ | |
# Run workflow: | |
# https://github.com/DFE-Digital/early-years-foundation-recovery/actions/workflows/staging.yml | |
# | |
# Build image: | |
# ghcr.io/dfe-digital/early-years-foundation-recovery:rc0.0.1 | |
# | |
# Deploy to: | |
# https://ey-recovery-staging.london.cloudapps.digital | |
# | |
name: Deploy Staging App | |
# on: | |
# workflow_dispatch: | |
# inputs: | |
# candidate: | |
# description: Create release candidate version ("rcx.x.x") | |
# type: string | |
# required: true | |
# ref: | |
# description: Git ref or branch to deploy | |
# type: string | |
# required: true | |
# default: main | |
# push: | |
# tags: | |
# - rc* | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: staging | |
env: | |
WORKSPACE: staging | |
REGISTRY: ghcr.io/dfe-digital/early-years-foundation-recovery | |
steps: | |
- | |
name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.ref_name }} | |
- | |
name: Tag candidate | |
if: ${{ inputs.candidate }} | |
run: | | |
git tag --force ${{ inputs.candidate }} | |
git push --force origin refs/tags/${{ inputs.candidate }} | |
echo "HEAD=$(git rev-parse ${{ inputs.candidate }})" >> $GITHUB_ENV | |
- | |
name: Pin Terraform version | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.1.7 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: v0.9.1 | |
- | |
name: Login to Github Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
target: app | |
context: . | |
push: true | |
build-args: | | |
BUILDKIT_INLINE_CACHE=1 | |
SHA=${{ github.sha }} | |
cache-from: | | |
${{ env.REGISTRY }}:${{ github.sha }} | |
${{ env.REGISTRY }}:${{ inputs.ref || github.ref_name }} | |
tags: | | |
${{ env.REGISTRY }}:${{ github.sha }} | |
${{ env.REGISTRY }}:${{ inputs.candidate || github.ref_name }} | |
- | |
name: Deploy Release Candidate | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
TF_VAR_paas_cf_user: ${{ secrets.CLOUD_FOUNDRY_USERNAME }} | |
TF_VAR_paas_cf_password: ${{ secrets.CLOUD_FOUNDRY_PASSWORD }} | |
TF_VAR_paas_app_docker_image: ${{ env.REGISTRY }}:${{ inputs.candidate || github.ref_name }} | |
TF_VAR_paas_app_hostname: staging | |
TF_VAR_paas_app_env_secrets: ${{ toJson(secrets) }} | |
TF_VAR_paas_app_envs: ${{ toJson(env) }} | |
run: | | |
cd terraform/app | |
terraform init \ | |
-reconfigure \ | |
-input=false \ | |
-backend-config="bucket=${{ secrets.AWS_BUCKET }}" \ | |
-backend-config="key=${{ env.WORKSPACE }}/terraform.tfstate" | |
terraform plan \ | |
-var-file ../workspace-variables/${{ env.WORKSPACE }}.tfvars | |
terraform apply \ | |
-input=false \ | |
-auto-approve \ | |
-var-file ../workspace-variables/${{ env.WORKSPACE }}.tfvars |