Skip to content

Code change pipeline to development by @GeorgeGoodall-GovUk #1404

Code change pipeline to development by @GeorgeGoodall-GovUk

Code change pipeline to development by @GeorgeGoodall-GovUk #1404

Workflow file for this run

name: Code change pipeline
run-name: Code change pipeline to ${{ inputs.environment || 'development' }} by @${{ github.actor }}
on:
push:
workflow_dispatch:
inputs:
environment:
type: environment
description: The environment to deploy to.
jobs:
run-tests:
uses: ./.github/workflows/test.yml
with:
environment: '${{ inputs.environment }}'
secrets: inherit
detect-environments:
runs-on: ubuntu-latest
outputs:
environments: ${{ steps.environments.outputs.result }}
steps:
- uses: actions/github-script@v7
id: environments
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: json
script: |
if (context.payload?.inputs?.environment) return [context.payload?.inputs?.environment];
const {data: {environments}} =
await github.request(`GET /repos/${process.env.GITHUB_REPOSITORY}/environments`);
return environments.map(e => e.name)
deploy-changes:
needs: [run-tests, detect-environments]
strategy:
matrix:
environment: ['production', 'staging']
if: ${{ github.ref_name == 'main'}}
uses: ./.github/workflows/deploy.yml
with:
environment: '${{ matrix.environment }}'
secrets: inherit