forked from pion/srtp
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (63 loc) · 2.42 KB
/
generate-authors.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
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
# If this repository should have package specific CI config,
# remove the repository name from .goassets/.github/workflows/assets-sync.yml.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
name: generate-authors
on:
pull_request:
jobs:
checksecret:
runs-on: ubuntu-latest
outputs:
is_PIONBOT_PRIVATE_KEY_set: ${{ steps.checksecret_job.outputs.is_PIONBOT_PRIVATE_KEY_set }}
steps:
- id: checksecret_job
env:
PIONBOT_PRIVATE_KEY: ${{ secrets.PIONBOT_PRIVATE_KEY }}
run: |
echo "is_PIONBOT_PRIVATE_KEY_set: ${{ env.PIONBOT_PRIVATE_KEY != '' }}"
echo "::set-output name=is_PIONBOT_PRIVATE_KEY_set::${{ env.PIONBOT_PRIVATE_KEY != '' }}"
generate-authors:
needs: [checksecret]
if: needs.checksecret.outputs.is_PIONBOT_PRIVATE_KEY_set == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.PIONBOT_PRIVATE_KEY }}
- name: Generate the authors file
run: .github/generate-authors.sh
- name: Add the authors file to git
run: git add AUTHORS.txt
- name: Get last commit message
id: last-commit-message
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
COMMIT_MSG="${COMMIT_MSG//'%'/'%25'}"
COMMIT_MSG="${COMMIT_MSG//$'\n'/'%0A'}"
COMMIT_MSG="${COMMIT_MSG//$'\r'/'%0D'}"
echo "::set-output name=msg::$COMMIT_MSG"
- name: Get last commit author
id: last-commit-author
run: |
echo "::set-output name=msg::$(git log -1 --pretty='%aN <%ae>')"
- name: Check if AUTHORS.txt file has changed
id: git-status-output
run: |
echo "::set-output name=msg::$(git status -s | wc -l)"
- name: Commit and push
if: ${{ steps.git-status-output.outputs.msg != '0' }}
run: |
git config user.email $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\2/')
git config user.name $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\1/')
git add AUTHORS.txt
git commit --amend --no-edit
git push --force https://github.com/${GITHUB_REPOSITORY} $(git symbolic-ref -q --short HEAD)