-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (58 loc) · 2.19 KB
/
create_release_commit.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
name: Release Commit
on:
workflow_dispatch:
inputs:
version_name:
description: "Number of the version of the RDM to release"
required: true
type: string
jobs:
release_commit:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
CI_COMMIT_MESSAGE: "New RDM release: ${{inputs.version_name}}"
steps:
- name: checkhout
uses: actions/checkout@v3
- name: Commit changes
working-directory: ${{github.workspace}}
shell: bash
run: |
TODAY=$( date -u '+%Y-%m-%d' )
echo "${{inputs.version_name}} : $TODAY" >> RDM_version_history.txt
FILE_TO_COMMIT=RDM_version_history.txt
MESSAGE="$CI_COMMIT_MESSAGE"
SHA=$( git rev-parse master:$FILE_TO_COMMIT )
echo "SHA=$SHA" >> $GITHUB_ENV
CONTENT=$( base64 -i $FILE_TO_COMMIT )
echo "Push commit"
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \
--field message="$MESSAGE" \
--field content="$CONTENT" \
--field encoding="base64" \
--field branch="master" \
--field sha="$SHA" \
--silent
echo "Try request"
RESP=$(curl -L \
--fail \
--silent \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}} " \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/3LawsRobotics/3laws/git/tags \
-d '{"tag":"${{inputs.version_name}}","message":"$CI_COMMIT_MESSAGE","object":"$SHA","type":"commit"}')
echo "response $RESP"
SHA=$(echo $RESP | jq -r '.sha')
echo "sha: $SHA"
curl -L \
--fail \
--silent \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}} " \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/3LawsRobotics/3laws/git/refs \
-d '{"ref":"refs/tags/${{inputs.version_name}}","sha":"$SHA"}'