Code change pipeline to development by @rosado #189
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: 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: ${{ fromJSON(needs.detect-environments.outputs.environments) }} | |
if: ${{ github.ref_name == 'main' }} | |
uses: ./.github/workflows/deploy.yml | |
with: | |
environment: '${{ matrix.environment }}' | |
secrets: inherit | |