-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-opensource-interface.yml
72 lines (62 loc) · 2.53 KB
/
generate-opensource-interface.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
name: opensource-heartbeat
on:
# nightly at 2:30am
schedule:
- cron: 30 2 * * *
jobs:
Update:
name: Generate Open Source HeartBeat Interface
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Open Source Heartbeat Action
# Important! Update to release https://github.com/rseng/opensource-heartbeat-action
uses: rseng/opensource-heartbeat-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
query: 'location%3AStanford'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout New Branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_AGAINST: "master"
run: |
printf "GitHub Actor: ${GITHUB_ACTOR}\n"
export BRANCH_FROM="opensource-heartbeat/update-$(date '+%Y-%m-%d')"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
BRANCH_EXISTS=$(git ls-remote --heads origin ${BRANCH_FROM})
if [[ -z ${BRANCH_EXISTS} ]]; then
printf "Branch does not exist in remote.\n"
else
printf "Branch already exists in remote.\n"
exit 1
fi
git branch
git checkout -b "${BRANCH_FROM}" || git checkout "${BRANCH_FROM}"
git branch
git add docs/*
git add docs/_events/*
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git status
if git diff-index --quiet HEAD --; then
export OPEN_PULL_REQUEST=0
printf "No changes\n"
else
export OPEN_PULL_REQUEST=1
printf "Changes\n"
git commit -a -m "Automated deployment to update contributors $(date '+%Y-%m-%d')"
git push origin "${BRANCH_FROM}"
fi
echo "OPEN_PULL_REQUEST=${OPEN_PULL_REQUEST}" >> $GITHUB_ENV
echo "OPEN_PULL_REQUEST_FROM_BRANCH=${BRANCH_FROM}" >> $GITHUB_ENV
echo "PULL_REQUEST_TITLE=[opensource-heartbeat] ${BRANCH_FROM}" >> $GITHUB_ENV
echo "PULL_REQUEST_BODY=OpenSource Heartbeat events update automated pull request." >> $GITHUB_ENV
- name: Open Pull Request
uses: vsoch/[email protected]
if: ${{ env.OPEN_PULL_REQUEST == '1' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_BRANCH: "master"