PR setup for non-terraform files #345
-
Hi, I've used this action to deploy resources to multiple environments with a matrix and a merge queue (using the example as a starting point) and it works really well. 👍🏻 I'm using the This can be prevented by using admin permissions to merge - bypassing the rule set and the merge queue. I wonder if there is a different solution, perhaps using different branches, and therefore rules? I'm trying to avoid having multiple long lived branches (but if that is the way - that is the way 😉 ) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Excellent question, and I was just wondering about the broader adoption of merge queues within provisioning pipelines! As it happens, my current team is all-in on merge queues (hence the idea for sharing the It might help to know a bit more about your use case and workflow structure to cater the solution. For example, my repo has an "envs" folder for each environment's IaC, next to a "docs" folder as shown below. .
├── docs
└── envs
├── dev
├── prod
└── qa As a result, I want TF to run within each of the "envs" directory where changes is introduced—up to all 3 in parallel. So my first "Target" job is responsible for creating the matrix list for subsequent job ingestion. outputs:
targets: ${{ steps.process.outputs.directories }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: Check changed directories
id: directories
uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c # v45.0.3
with:
dir_names: true
dir_names_max_depth: 2
files: envs/**
matrix: true The if: ${{ needs.Target.outputs.targets != '[]' }}
needs: [Target]
strategy:
fail-fast: false
matrix:
targets: ${{ fromJSON(needs.Target.outputs.targets) }} Finally, I have the third "Notify" job which lets me know if any prior job(s) failed and produces the appropriate exit status. if: ${{ !cancelled() }}
needs: [Target, Provision]
steps:
- name: Notify Slack
if: ${{ github.event_name == 'merge_group' && contains(needs.*.result, 'failure') }}
uses: gamesight/slack-workflow-status@68bf00d0dbdbcb206c278399aa1ef6c14f74347a # v1.3.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Exit status
run: exit ${{ contains(needs.*.result, 'failure') && 1 || 0 }} Pros
Cons
Keen to know how you get along (and if you have better suggestions!) Aside, I just shared a post on Reddit, in case you'd like to ask/share with a broader audience. |
Beta Was this translation helpful? Give feedback.
Excellent question, and I was just wondering about the broader adoption of merge queues within provisioning pipelines!
As it happens, my current team is all-in on merge queues (hence the idea for sharing the
merge_group
andmatrix
examples) and the status check problem of non-TF pull requests was the first one to be tackled.It might help to know a bit more about your use case and workflow structure to cater the solution. For example, my repo has an "envs" folder for each environment's IaC, next to a "docs" folder as shown below.
As a result, I want TF to run within each of the "envs" directory where changes is introduced—up to all 3…