-
Notifications
You must be signed in to change notification settings - Fork 7
134 lines (129 loc) · 5.61 KB
/
sc4pac.yaml
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Sc4pac CI
on:
push:
branches: [ "main", "action" ]
pull_request_target:
branches: [ "main" ]
workflow_dispatch: # for manually triggering the workflow from Actions tab
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: python -m pip install --upgrade PyYAML jsonschema
- name: Checkout pull request
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
persist-credentials: false
# ref: "${{ github.event.pull_request.merge_commit_sha }}"
# As merge_commit_sha is not up-to-date due to mergeability check, we use actual PR head for now; see https://github.com/actions/checkout/issues/518#issuecomment-1757453837
# ref: ${{ github.event.pull_request.head.sha }}
# (This merge might correspond to a newer commit than the one that triggered this workflow, in case the PR was updated in the meantime -> ok)
ref: ${{ format('refs/pull/{0}/merge', github.event.pull_request.number) }}
path: tmp
sparse-checkout: |
src/yaml
- name: Check sc4pac yaml schema (pull_request_target)
if: ${{ github.event_name == 'pull_request_target' }}
# With pull_request_target, the `main` branch is checked out, not the PR.
# We checked out PR into `tmp` and run script from main branch.
run: cd tmp && python ../.github/sc4pac-yaml-schema.py src/yaml
- name: Check sc4pac yaml schema (push)
if: ${{ github.event_name != 'pull_request_target' }}
# We are on an actual branch of the repository, so run script here in the repository.
run: python .github/sc4pac-yaml-schema.py src/yaml
# requires STEX_API_KEY, so job is skipped in forks
url-check:
if: ${{ github.repository == 'memo33/sc4pac' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# to allow diff of other commit
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: python -m pip install --upgrade PyYAML jsonschema python-dateutil
- name: Checkout pull request
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
persist-credentials: false
# ref: "${{ github.event.pull_request.merge_commit_sha }}"
# As merge_commit_sha is not up-to-date due to mergeability check, we use actual PR head for now; see https://github.com/actions/checkout/issues/518#issuecomment-1757453837
# ref: ${{ github.event.pull_request.head.sha }}
# (This merge might correspond to a newer commit than the one that triggered this workflow, in case the PR was updated in the meantime -> ok)
ref: ${{ format('refs/pull/{0}/merge', github.event.pull_request.number) }}
path: tmp
sparse-checkout: |
src/yaml
- name: Check STEX URLs (pull_request_target)
if: ${{ github.event_name == 'pull_request_target' }}
env:
STEX_API_KEY: ${{ secrets.STEX_API_KEY }}
# We checked out PR into `tmp` and run script from main branch.
run: cd tmp && git diff --no-index --name-only ../src/yaml src/yaml | xargs --delimiter '\n' python ../.github/st-check-updates.py --mode=id
- name: Check STEX URLs (push)
if: ${{ github.event_name != 'pull_request_target' }}
env:
STEX_API_KEY: ${{ secrets.STEX_API_KEY }}
PREVIOUS_COMMIT: ${{ github.event.before }}
# We are on an actual branch of the repository, so run script here in the repository.
# TODO This is not perfect yet, as `before` does not exist on new branches or forced pushes.
run: git diff --name-only "$PREVIOUS_COMMIT" -- src/yaml | xargs --delimiter '\n' python .github/st-check-updates.py --mode=id
deploy:
needs: lint # url-check is not needed as ST is flaky
if: ${{ github.repository == 'memo33/sc4pac' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request_target' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- name: Build sc4pac executable
run: cd sc4pac-tools && sbt assembly && ./sc4pac --version
- name: Build channel and website
run: make gh-pages-no-lint
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
# note that this action dereferences our `latest` symlinks, but that's not a huge problem, it just duplicates each json file
uses: actions/upload-pages-artifact@v3
with:
path: "gh-pages"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
permissions:
pages: write
id-token: write