generated from curseforge-mirror/template
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (60 loc) · 2.27 KB
/
setup-repo.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
name: Setup Repository
on:
workflow_dispatch:
push:
paths:
- setup.json
workflow_run:
workflows: ["Template Sync"]
types:
- completed
jobs:
set-up-repo:
if: "!contains(github.event.head_commit.message, 'Initial')"
name: Reinitialize repository
runs-on: ubuntu-latest
env:
REPO_SETUP_TOKEN: ${{ secrets.REPO_SETUP_TOKEN }}
steps:
- name: Do not run on template repository
shell: bash
run: |
curl --silent -X GET \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.baptiste-preview+json" \
https://api.github.com/repos/$GITHUB_REPOSITORY \
| jq --exit-status '.is_template == false';
- uses: actions/checkout@v3
with:
token: ${{ env.REPO_SETUP_TOKEN || secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Run Setup Script
run: python repo_setup.py
- name: Update Repo Description
shell: bash
env:
ADDON_AUTHOR: ${{ env.ADDON_AUTHOR }}
ADDON_NAME: ${{ env.ADDON_NAME }}
run: |
curl --silent -X PATCH \
-H "Authorization: token ${{ env.REPO_SETUP_TOKEN || secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/$GITHUB_REPOSITORY \
-d "{\"description\":\"Mirror of $ADDON_AUTHOR's $ADDON_NAME.\", \"has_issues\":false, \"has_wiki\":false}" > /dev/null
- name: Check for Git Changes
id: vars
run: echo ::set-output name=has_git_changes::$(if [ -n "$(git status -s -uno)"]; then echo NO; else echo YES; fi)
- name: Commit files
if: steps.vars.outputs.has_git_changes == 'YES'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update Repo with Addon Info" -a
- name: Push changes
if: steps.vars.outputs.has_git_changes == 'YES'
uses: ad-m/github-push-action@master
with:
github_token: ${{ env.REPO_SETUP_TOKEN || secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}