Skip to content

test

test #27

Workflow file for this run

name: 'Deploy'
on:
pull_request:
branches: [master]
jobs:
run-tests:
name: 'Run frontend tests'
runs-on: ubuntu-latest
defaults:
run:
working-directory: 'frontend'
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Task A.1:
#
# Answer A.1:
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn test
#
build:
name: 'Build Docker image and push to registry'
# Task A.2:
#
# Answer A.2:
needs: [run-tests]
#
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image to registry
uses: docker/build-push-action@v5
with:
push: 'true'
tags: 'ghcr.io/${{ github.repository }}/${{ github.head_ref }}:latest'
context: 'frontend'
deploy:
name: 'Deploy using Terraform'
runs-on: ubuntu-latest
needs: [build]
env:
TF_VAR_revision_suffix: ${{ github.sha }}
TF_VAR_my_name: ${{ github.head_ref }}
TF_VAR_repository: ${{ github.repository }}
ARM_CLIENT_ID: ${{ vars.ARM_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ vars.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }}
ARM_USE_OIDC: 'true'
permissions:
contents: read
id-token: write
environment: prod
defaults:
run:
working-directory: 'terraform'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Init Terraform
run: terraform init
- name: Set Terraform workspace
run: terraform workspace new $TF_VAR_my_name || terraform workspace select $TF_VAR_my_name
- name: Run Terraform plan
run: terraform plan
- name: Run Terraform apply
# Task A.3
#
# Answer A.3
run: terraform apply -auto-approve
#