generated from ModelAtlasofTheEarth/mate-model-template
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (97 loc) · 3.38 KB
/
copy-files.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Copy Files
on:
issues:
types:
- labeled
jobs:
update-doi:
if: contains(github.event.label.name, 'model published')
runs-on: ubuntu-latest
outputs:
success: ${{ steps.update-doi.outputs.success }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- run: pip install -r .github/scripts/requirements.txt
- name: create m@te bot token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: update doi
id: update-doi
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
REPO_NAME: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
SUCCESS=$(python3 .github/scripts/update_doi.py)
echo "success=${SUCCESS}" >> $GITHUB_OUTPUT
- name: Clean gitkeep files from repo
run: |
git pull
for line in $(git ls-files | grep './gitkeep'); do
EXTRA_FILES=$(git ls-files $(dirname "$line") | wc -l)
if [ $EXTRA_FILES -ne "1" ]; then
rm "$line"
fi
done
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Remove unnecessary .gitkeep
copy-files:
needs: update-doi
if: ${{ needs.update-doi.outputs.success == 'True' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- run: pip install -r .github/scripts/requirements.txt
- name: create token for website repo
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: 'website,model_submission'
- name: create branch
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: 'website'
BRANCH_NAME: ${{ github.event.repository.name }}
run: |
python3 .github/scripts/create_branch.py
- name: copy files to website repo
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
SOURCE_REPO_OWNER: ${{ github.repository_owner }}
SOURCE_REPO_NAME: ${{ github.event.repository.name }}
SOURCE_PATH: 'website_material'
TARGET_REPO_OWNER: ${{ github.repository_owner }}
TARGET_REPO_NAME: 'website'
TARGET_REPO_BRANCH: ${{ github.event.repository.name }}
TARGET_PATH: 'src/pages/models/${{ github.event.repository.name }}'
run: |
python3 .github/scripts/copy_files.py
- name: update submission issue
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: 'model_submission'
SLUG: ${{ github.event.repository.name }}
run: |
python3 .github/scripts/update_labels.py