generated from ModelAtlasofTheEarth/mate-model-template
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (92 loc) · 3.69 KB
/
new-actions.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
name: New actions
on:
push:
branches:
- 'main'
paths:
- '.github/**'
jobs:
find-repos:
if: ${{ github.event.repository.name == 'mate_model_template' }}
runs-on: ubuntu-latest
outputs:
repo_matrix: ${{ steps.found-repos.outputs.repos }}
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 token
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 }}
- name: Find repos
id: found-repos
env:
TOKEN: ${{ steps.app-token.outputs.token }}
REPO: ${{ github.event.repository.name }}
ORG: ${{ github.repository_owner }}
run: |
REPOS=$(python3 .github/scripts/find_repos.py)
echo "repos=$(jq -cn --argjson environments "$REPOS" '{repo: $environments}')" >> $GITHUB_OUTPUT
jq -cn --argjson environments "$REPOS" '{repo: $environments}'
copy-PR:
needs: find-repos
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.find-repos.outputs.repo_matrix) }}
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 token for 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: ${{ matrix.repo }}
- name: create branch
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ matrix.repo }}
BRANCH_NAME: 'template-update'
run: |
python3 .github/scripts/create_branch.py
- name: copy files to repo
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
SOURCE_REPO_OWNER: ${{ github.repository_owner }}
SOURCE_REPO_NAME: ${{ github.event.repository.name }}
SOURCE_PATH: '.github'
TARGET_REPO_OWNER: ${{ github.repository_owner }}
TARGET_REPO_NAME: ${{ matrix.repo }}
TARGET_REPO_BRANCH: 'template-update'
TARGET_PATH: '.github'
run: |
python3 .github/scripts/copy_files.py
- name: create pull request
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ matrix.repo }}
PR_TITLE: "New scripts from template repo"
GITHUB_EVENT_PATH: ${{ github.event_path }}
HEAD_BRANCH: 'template-update'
BASE_BRANCH: 'main'
run: |
python3 .github/scripts/pull_request.py