Repository navigation
52 lines (47 loc) · 1.93 KB
/
Copy pathcontributors_automated.yml
File metadata and controls
52 lines (47 loc) · 1.93 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
name: contributors-automated
on:
schedule:
# Nightly at 2:30am
- cron: 30 2 * * *
jobs:
GenerateSourcecred:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v1
- name: Cache Data
id: cache-data
uses: actions/cache@v1
with:
path: sourcecred_data
key: ${{ runner.os }}-sourcecred_data
- name: Generate SourceCred Graphic
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SOURCECRED_GITHUB_TOKEN=${TOKEN} docker run -i --rm -v sourcecred_data:/data -e SOURCECRED_GITHUB_TOKEN sourcecred/sourcecred:dev load ${GITHUB_REPOSITORY}
SOURCECRED_GITHUB_TOKEN=${TOKEN} docker run -i --rm -v sourcecred_data:/data sourcecred/sourcecred:dev scores ${GITHUB_REPOSITORY} > scores.json
SOURCECRED_GITHUB_TOKEN=${TOKEN} docker run -i --rm -e SOURCECRED_GITHUB_TOKEN sourcecred/widgets < scores.json > contributors.svg
cat contributors.svg
- name: Update Branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPDATE_BRANCH: contributors-automated
run: |
printf "GitHub Actor: ${GITHUB_ACTOR}\n"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git branch
printf "Branch to push to is ${UPDATE_BRANCH}\n"
git checkout -b ${UPDATE_BRANCH} || git checkout ${UPDATE_BRANCH}
git branch
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git pull origin ${UPDATE_BRANCH} || printf "Branch not yet on remote\n"
git add contributors.svg
if git diff-index --quiet HEAD --; then
printf "No changes\n"
else
printf "Changes\n"
git commit -m "Automated deployment to update contributors.svg $(date '+%Y-%m-%d')"
git push origin ${UPDATE_BRANCH}
fi