-
Notifications
You must be signed in to change notification settings - Fork 41
101 lines (89 loc) · 3.65 KB
/
promote.yml
File metadata and controls
101 lines (89 loc) · 3.65 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Promote Component
on:
workflow_dispatch:
inputs:
component:
description: 'Component name to promote'
required: true
type: string
ref:
description: 'Git ref/tag to promote. For puppet-runtime, use the tag that has been built and uploaded to openvox-artifacts.'
required: true
type: string
branch:
description: 'Branch to promote to (defaults to main)'
required: false
default: 'main'
type: string
permissions: {}
env:
GIT_AUTHOR_NAME: OpenVoxProjectBot
GIT_AUTHOR_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
GIT_COMMITTER_NAME: OpenVoxProjectBot
GIT_COMMITTER_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
jobs:
promote:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
token: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
- name: Add SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}" > ~/.ssh/github_actions
chmod 600 ~/.ssh/github_actions
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add ~/.ssh/github_actions
- name: Setup git
run: |
git config --global user.email "$GIT_AUTHOR_EMAIL"
git config --global user.name "$GIT_AUTHOR_NAME"
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/github_actions
git config --global commit.gpgsign true
git config --global tag.gpgsign true
- name: Validate component exists
run: |
component="${{ inputs.component }}"
if [[ ! -f "packaging/configs/components/${component}.json" ]]; then
echo "::error::Could not find packaging/configs/components/${component}.json"
exit 1
fi
- name: Generate component JSON
id: generate
run: |
component="${{ inputs.component }}"
ref="${{ inputs.ref }}"
if [[ "${component}" =~ ^(puppet-runtime|openssl-fips)$ ]]; then
# Munge the ref: replace - with .
munged="${ref//-/.}"
json="{\"location\":\"https://s3.osuosl.org/openvox-artifacts/${component}/${ref}/\",\"version\":\"${munged}\"}"
else
json="{\"url\":\"https://github.com/openvoxproject/${component}.git\",\"ref\":\"${ref}\"}"
fi
echo "json=${json}" >> "$GITHUB_OUTPUT"
echo "Generated JSON: ${json}"
- name: Write component JSON
run: |
component="${{ inputs.component }}"
echo '${{ steps.generate.outputs.json }}' > "packaging/configs/components/${component}.json"
echo "Wrote packaging/configs/components/${component}.json:"
cat "packaging/configs/components/${component}.json"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
with:
commit-message: "Promote ${{ inputs.component }} ${{ inputs.ref }}"
branch: "promote/${{ inputs.component }}/${{ inputs.ref }}"
delete-branch: true
title: "Promote ${{ inputs.component }} ${{ inputs.ref }}"
token: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
assignees: '${{ github.triggering_actor }}'
author: '${{ env.GIT_AUTHOR_NAME }} <${{ env.GIT_AUTHOR_EMAIL }}>'
committer: '${{ env.GIT_COMMITTER_NAME }} <${{ env.GIT_COMMITTER_EMAIL }}>'
base: ${{ inputs.branch }}
body: |
Automated promotion of ${{ inputs.component }} to ref ${{ inputs.ref }}.