-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (95 loc) · 3.73 KB
/
release-my-rock.yml
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
name: Release my ROCK
on:
workflow_dispatch:
inputs:
rocks-project:
description: "Repo (eg. 'mock-rock')"
required: true
type: string
rock:
description: "ROCK name (eg. 'mock-one')"
required: true
type: string
revision:
description: "Revision to release"
required: true
type: string
track:
description: "Release to track"
required: true
type: string
risk:
description: "Release to risk"
required: true
default: "edge"
type: choice
options:
- edge
- beta
- candidate
- stable
env:
ROCK_PROJECT_CHECKOUT_LOCATION: "${{ github.workspace }}/rocks-project"
jobs:
create-relese-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install -r requirements.txt
# Fetch GH App token for performing org operation during the pipeline
- name: Get token for Organization Workflow
id: get_token
uses: machine-learning-apps/actions-app-token@master
with:
APP_PEM: ${{ secrets.APP_PEM }}
APP_ID: ${{ secrets.APP_ID }}
# Check if user can make request, and if request is legit
- name: Validate release request
id: request-validator
run: |
./validate-release-request.py --token ${{ steps.get_token.outputs.app_token }} \
--repo ${{ inputs.rocks-project }} \
--rock-name ${{ inputs.rock }} \
--revision ${{ inputs.revision }} \
--risk ${{ inputs.risk }} \
--track ${{ inputs.track }}
# Get the corresponding ROCK build tag
- name: Checkout ${{ steps.request-validator.outputs.build-tag }} from the ROCK repo (${{ inputs.rocks-project }})
uses: actions/checkout@v3
with:
repository: rockcrafters/${{ inputs.rocks-project }}
ref: ${{ steps.request-validator.outputs.build-tag }}
token: ${{ steps.get_token.outputs.app_token }}
path: ${{ env.ROCK_PROJECT_CHECKOUT_LOCATION }}
# Create release request via a Git tag
- name: Create Git tag
id: git-tag
run: |
set -eux
echo "_,${{ inputs.rock }},${{ steps.request-validator.outputs.rock-version }},_,_,${{ inputs.revision }},_" > $PWD/pub.txt
./create-git-tags.sh \
${{ steps.get_token.outputs.app_token }} \
$PWD/pub.txt \
_ \
rockcrafters/${{ inputs.rocks-project }} \
$(cd $ROCK_PROJECT_CHECKOUT_LOCATION && git rev-parse HEAD) \
${{ inputs.track }} \
${{ inputs.risk }} \
true
echo "::set-output name=commit::$(cd $ROCK_PROJECT_CHECKOUT_LOCATION && git rev-parse HEAD)"
# Announce the Git tags have been created
- name: Report that the release has been requested
uses: LouisBrunner/[email protected]
continue-on-error: true
with:
token: ${{ steps.get_token.outputs.app_token }}
name: Manual release request (${{ inputs.rock }}(${{ inputs.revision }}) to ${{ inputs.track }}/${{ inputs.risk }})
sha: ${{ steps.git-tag.outputs.commit }}
repo: rockcrafters/${{ inputs.rocks-project }}
conclusion: success
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: |
{"summary": "Received a manual request for releasing ${{ inputs.rock }} (revision ${{ inputs.revision }}) to ${{ inputs.track }}/${{ inputs.risk }}. See the new Git tag ${{ steps.git-tag.outputs.release-tags }}"}