Skip to content

Commit 046e964

Browse files
build-cd v7: !update-configs: Prerelease to Model Configs Pipeline (#321)
* Add get-pr-deployments action * Use get-pr-deployments action * Added workflow for !update-configs comment command * Allow the command to only be run by users with write perms * Split into 3 jobs - Setup, Update and Post * Remove pip cache * Move build-cd into Result * Remove temp refs, update all to v7 * Update .github/workflows/ci-command-configs.yml Co-authored-by: Aidan Heerdegen <aidan.heerdegen@anu.edu.au> Signed-off-by: Tommy Gatti <tommy.gatti@outlook.com> * Add scripts.model_config_manifest.prerelease_update script instead of yq invocation, add tests * Check args are non empty before iteration, use read * Update get-pr-deployments README.md * Remove actions-style inputs * Remove check for config/auto-configs-pr.json as it should fail when checking against schema * Make python version an env * Update regex for root-sbds in module load replacement * Make config updates a matrix job, split opening PR and repro check into their own steps --------- Signed-off-by: Tommy Gatti <tommy.gatti@outlook.com> Co-authored-by: Aidan Heerdegen <aidan.heerdegen@anu.edu.au>
1 parent 51039f5 commit 046e964

15 files changed

Lines changed: 813 additions & 39 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Get PR Deployments
2+
3+
Action that returns the number of deployments on a given PR branch.
4+
5+
## Inputs
6+
7+
| Name | Description | Required | Default | Example |
8+
| ---- | ----------- | -------- | ------- | ------- |
9+
| `pr` | The pull request number to check for deployments of all kinds | `true` | N/A | `21` |
10+
| `repository` | The repository to check for deployments | `false` | Value of `github.repository` | `"ACCESS-NRI/ACCESS-OM2"` |
11+
| `token` | The GitHub token to use for API requests | `false` | Value of `github.token` | `"ghp_XXXX"` |
12+
13+
## Outputs
14+
15+
| Name | Description | Example |
16+
| ---- | ----------- | ------- |
17+
| `deployments` | The total number of deployments for the given PR (from commits and `!redeploy`s) | `24` |
18+
19+
## Example
20+
21+
```yaml
22+
# ...
23+
jobs:
24+
deployments:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- id: pr-deploys
28+
uses: access-nri/build-cd/.github/actions/get-pr-deployments@v6
29+
with:
30+
pr: 12
31+
32+
- run: echo "There have been ${{ steps.pr-deploys.outputs.deployments }} total deployments in this PR, including both regular commit deployments and redeployments"
33+
```
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Get PR Deployments
2+
description: Action that returns how many deployments were made in a PR (both from commits and !redeploys)
3+
author: Tommy Gatti
4+
inputs:
5+
pr:
6+
required: true
7+
description: The pull request number to check for deployments of all kinds
8+
repository:
9+
required: false
10+
default: ${{ github.repository }}
11+
description: The repository to check for deployments
12+
token:
13+
required: false
14+
default: ${{ github.token }}
15+
description: The GitHub token to use for API requests
16+
outputs:
17+
deployments:
18+
description: The total number of deployments for the given PR (from commits and !redeploys)
19+
value: ${{ steps.total.outputs.number }}
20+
runs:
21+
using: composite
22+
# Essentially, count all the deployment entries that match the given branch, as well as
23+
# all the `!redeploy` comments, to get the next deployment number.
24+
# See https://docs.github.com/en/rest/deployments/deployments?apiVersion=2022-11-28#list-deployments
25+
steps:
26+
- name: Get PR HEAD
27+
id: pr
28+
shell: bash
29+
env:
30+
GH_TOKEN: ${{ inputs.token }}
31+
run: |
32+
head=$(gh pr view ${{ inputs.pr }} --repo ${{ inputs.repository }} --json headRefName --jq .headRefName)
33+
echo "HEAD of PR #${{ inputs.pr }} in ${{ inputs.repository }} is $head"
34+
echo "head=$head" >> $GITHUB_OUTPUT
35+
36+
- name: Get commit deployments for PR
37+
id: commit
38+
shell: bash
39+
env:
40+
GH_TOKEN: ${{ inputs.token }}
41+
# We --slurp the results because --paginate introduces potentially multiple array results
42+
run: |
43+
deployments=$(gh api \
44+
-H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
45+
--paginate --slurp \
46+
/repos/${{ inputs.repository }}/deployments \
47+
| jq '[select(.[][].ref == "${{ steps.pr.outputs.head }}")] | length'
48+
)
49+
echo "Found $deployments deployments for PR #${{ inputs.pr }} in ${{ inputs.repository }}"
50+
echo "deployments=$deployments" >> $GITHUB_OUTPUT
51+
52+
- name: Get !redeploys from comments
53+
id: comment
54+
shell: bash
55+
env:
56+
GH_TOKEN: ${{ inputs.token }}
57+
run: |
58+
redeployments=$(gh pr view ${{ inputs.pr }} --repo ${{ github.repository }} \
59+
--json comments \
60+
--jq '[.comments[] | select(.body | startswith("!redeploy"))] | length'
61+
)
62+
echo "Found $redeployments redeploy comments for PR #${{ inputs.pr }} in ${{ inputs.repository }}"
63+
echo "redeployments=$redeployments" >> $GITHUB_OUTPUT
64+
65+
- name: Return total deployments
66+
id: total
67+
shell: bash
68+
run: |
69+
total=$(( ${{ steps.commit.outputs.deployments }} + ${{ steps.comment.outputs.redeployments }} ))
70+
echo "Found $total deployments across commits (${{ steps.commit.outputs.deployments }}) and redeploys (${{ steps.comment.outputs.redeployments }}) for PR #${{ inputs.pr }} in ${{ inputs.repository }}"
71+
echo "number=$total" >> $GITHUB_OUTPUT

.github/workflows/cd.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
9292
- name: Generate Deployment Target Matrix
9393
id: target
94-
uses: access-nri/build-cd/.github/actions/get-target-matrix@v6
94+
uses: access-nri/build-cd/.github/actions/get-target-matrix@v7
9595
with:
9696
targets: ${{ vars.RELEASE_DEPLOYMENT_TARGETS }}
9797

@@ -108,7 +108,7 @@ jobs:
108108
with:
109109
repository: access-nri/build-cd
110110

111-
- uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v6
111+
- uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v7
112112
with:
113113
settings-path: ./config/settings.json
114114
target: ${{ matrix.target }}
@@ -126,7 +126,7 @@ jobs:
126126

127127
- name: Get root spec ref
128128
id: tag
129-
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v6
129+
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v7
130130
with:
131131
spack-manifest-path: ${{ inputs.spack-manifest-path }}
132132

@@ -180,7 +180,7 @@ jobs:
180180
strategy:
181181
matrix:
182182
target: ${{ fromJson(needs.defaults.outputs.targets) }}
183-
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v6
183+
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v7
184184
with:
185185
deployment-target: ${{ matrix.target }}
186186
deployment-ref: ${{ github.ref_name }}

.github/workflows/ci-closed.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Generate Deployment Target Matrix
4040
id: target
41-
uses: access-nri/build-cd/.github/actions/get-target-matrix@v6
41+
uses: access-nri/build-cd/.github/actions/get-target-matrix@v7
4242
with:
4343
targets: ${{ vars.PRERELEASE_DEPLOYMENT_TARGETS }}
4444

@@ -50,7 +50,7 @@ jobs:
5050
matrix:
5151
target: ${{ fromJson(needs.setup.outputs.targets) }}
5252
fail-fast: false
53-
uses: access-nri/build-cd/.github/workflows/undeploy-1-start.yml@v6
53+
uses: access-nri/build-cd/.github/workflows/undeploy-1-start.yml@v7
5454
with:
5555
version-pattern: ${{ inputs.root-sbd }}-pr${{ github.event.pull_request.number }}-*
5656
target: ${{ matrix.target }}

0 commit comments

Comments
 (0)