forked from coast-guard/coasts
-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (54 loc) · 1.79 KB
/
update-policy.yml
File metadata and controls
59 lines (54 loc) · 1.79 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Update CLI Policy
on:
workflow_dispatch:
inputs:
policy:
description: "Update policy tier"
required: true
type: choice
options:
- nudge
- required
- auto
minimum_version:
description: "Minimum required version (e.g. 0.1.0)"
required: true
default: "0.1.0"
message:
description: "Custom message to display to users (optional)"
required: false
default: ""
jobs:
update-policy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.POLICY_PUSH_TOKEN }}
- name: Validate minimum_version exists as a release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="v${{ github.event.inputs.minimum_version }}"
if ! gh release view "$VERSION" > /dev/null 2>&1; then
echo "::error::Release $VERSION does not exist. Available releases:"
gh release list --limit 20
exit 1
fi
echo "Validated: release $VERSION exists"
- name: Update policy file
run: |
cat > cli-update-policy.json << EOF
{
"policy": "${{ github.event.inputs.policy }}",
"minimum_version": "${{ github.event.inputs.minimum_version }}",
"message": "${{ github.event.inputs.message }}"
}
EOF
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add cli-update-policy.json
git commit -m "chore: update CLI policy to ${{ github.event.inputs.policy }} (min: ${{ github.event.inputs.minimum_version }})"
git push