-
Notifications
You must be signed in to change notification settings - Fork 1
46 lines (40 loc) · 1.29 KB
/
base.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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