Last active
September 15, 2023 11:04
-
-
Save dgk/c9bd9ec3c07ee808fdea2cfc7000caa5 to your computer and use it in GitHub Desktop.
env matrix for digger
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
projects: | |
- name: dev | |
dir: envs/dev | |
workflow: dev | |
include_patterns: | |
- ../../modules/** | |
- name: stage | |
dir: envs/stage | |
workflow: stage | |
include_patterns: | |
- ../../modules/** | |
- name: prod | |
dir: envs/prod | |
workflow: prod | |
include_patterns: | |
- ../../modules/** | |
workflows: | |
dev: | |
env_vars: | |
state: | |
- name: GCP_CREDENTIALS | |
value_from: DEV_GCP_CREDENTIALS | |
commands: | |
- name: GCP_CREDENTIALS | |
value_from: DEV_GCP_CREDENTIALS | |
stage: | |
env_vars: | |
state: | |
- name: GCP_CREDENTIALS | |
value_from: STAGE_GCP_CREDENTIALS | |
commands: | |
- name: GCP_CREDENTIALS | |
value_from: STAGE_GCP_CREDENTIALS | |
prod: | |
env_vars: | |
state: | |
- name: GCP_CREDENTIALS | |
value_from: PROD_GCP_CREDENTIALS | |
commands: | |
- name: GCP_CREDENTIALS | |
value_from: PROD_GCP_CREDENTIALS |
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: Digger | |
on: | |
workflow_call: | |
inputs: | |
env: | |
required: true | |
type: string | |
secrets: | |
GCP_CREDENTIALS: | |
required: true | |
jobs: | |
digger: | |
name: Digger run on ${{ inputs.env }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.env }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
clean: false | |
ref: ${{ fromJSON(format('[null, "refs/pull/{0}/merge"]', github.event.issue.number))[github.event_name == 'issue_comment'] }} | |
- name: Get diff | |
uses: technote-space/get-diff-action@v6 | |
id: diff | |
with: | |
SET_ENV_NAME: '' | |
SET_ENV_NAME_FILTERED_DIFF: '' | |
SET_ENV_NAME_MATCHED_FILES: '' | |
DIFF_FILTER: 'AMRCD' | |
MINIMATCH_OPTION_DOT: true | |
PATTERNS: | | |
modules/** | |
envs/${{ inputs.env }}/** | |
- name: digger run on ${{ inputs.env }} | |
if: ${{ steps.diff.outputs.count > 0 }} | |
uses: diggerhq/digger@v0.1.31 | |
with: | |
configure-checkout: false | |
setup-terraform: true | |
terraform-version: v1.2.4 | |
setup-google-cloud: true | |
google-auth-credentials: ${{ secrets.GCP_CREDENTIALS }} | |
env: | |
LOCK_PROVIDER: gcp | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GOOGLE_STORAGE_BUCKET: devops-expirements-lock |
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: Matrix | |
on: | |
pull_request: | |
branches: | |
- master | |
types: | |
- closed | |
- opened | |
- reopened | |
- synchronize | |
issue_comment: | |
types: | |
- created | |
if: contains(github.event.comment.body, 'digger') | |
workflow_dispatch: | |
jobs: | |
env: | |
strategy: | |
max-parallel: 1 | |
matrix: | |
env: | |
- dev | |
- stage | |
- prod | |
uses: ./.github/workflows/digger.yml | |
with: | |
env: ${{ matrix.env }} | |
secrets: | |
GCP_CREDENTIALS: ${{ secrets[format('{0}_GCP_CREDENTIALS', matrix.env)] }} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment