This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (73 loc) · 2.63 KB
/
auto_merge.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
name: Automerge and Update Plots
# Controls when the action will run.
on:
pull_request_target:
# Allows you to run this workflow manually from the Actions tab, only use for testing
workflow_dispatch:
permissions:
pull-requests: write
contents: write
jobs:
# first check if dependabot made the PR
check-dependabot:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
create-plots:
# if a dependabot PR, then update the plots if its the JHU branch
runs-on: ubuntu-latest
needs: [check-dependabot]
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: 'recursive'
- id: get-dataset
run: |
id=$(echo ${GITHUB_HEAD_REF#refs/heads/} | cut -d/ -f5 | cut -d- -f1)
echo "::set-output name=id::$id"
- name: Set up Python
if: ${{ steps.get-dataset.outputs.id == 'jhu'}}
uses: actions/setup-python@v2
with:
python-version: 3.7
# Runs a single command using the runners shell
- name: Install dependencies and update plots
if: ${{ steps.get-dataset.outputs.id == 'jhu'}}
run: |
pip install -r requirements.txt
pip install .
echo "Updating plots on ${GITHUB_HEAD_REF#refs/heads/}"
python .github/update_plots.py
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
git config --global user.name github-actions
git add .github/*.png
python .github/update_date.py
git add .github/date_last_updated.yml
git commit --message 'Update plots'
git remote remove origin
git remote add origin https://${{ secrets.PA_TOKEN }}@github.com/slwatkins/covid.git
echo "Pushing to ${GITHUB_HEAD_REF#refs/heads/}"
git push --quiet origin HEAD:${GITHUB_HEAD_REF#refs/heads/} > /dev/null 2>&1
dependabot-merge:
# merge the PR to master
name: Merge dependabot updates
needs: [create-plots]
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Merge Dependabot PR
uses: nick-invision/retry@v2
with:
max_attempts: 3
timeout_minutes: 10
retry_on: error
command: gh pr merge --rebase "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}