Repository navigation
123 lines (106 loc) · 3.89 KB
/
Copy pathupdate-pages.yml
File metadata and controls
123 lines (106 loc) · 3.89 KB
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
---
name: Update
permissions: {}
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '0 * * * *'
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
MAX_NEW_ASSETS: 50 # Set to 0 for unlimited, or any positive number to limit downloads per run
jobs:
update:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Check dist branch
id: dist_branch
run: |
if git ls-remote --exit-code --heads origin dist >/dev/null; then
echo "exists=true" >> "${GITHUB_OUTPUT}"
else
status=$?
if [ "$status" -ne 2 ]; then
exit "$status"
fi
echo "exists=false" >> "${GITHUB_OUTPUT}"
fi
- name: Checkout dist branch
if: steps.dist_branch.outputs.exists == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: dist
path: dist
persist-credentials: false # otherwise, pushes use GITHUB_TOKEN instead of the personal token
fetch-depth: 1
- name: Create dist branch
if: steps.dist_branch.outputs.exists == 'false'
run: |
mkdir dist
cd dist
git init --initial-branch=dist
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
- name: Get organization repositories, download assets, and update package index
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GH_BOT_TOKEN || github.token }}
script: |
// Import the sync assets with metadata module
const { syncAssetsWithMetadata } = require('./.github/scripts/sync-assets-with-metadata.js');
// Check if this is a pull request event
const isPullRequest = context.eventName === 'pull_request';
// Get the max new assets limit from environment
const maxNewAssets = parseInt(process.env.MAX_NEW_ASSETS) || 0;
// Change working directory to dist for file operations
process.chdir('./dist');
// Run the asset synchronization and write packages.json
await syncAssetsWithMetadata(github, context, isPullRequest, maxNewAssets);
- name: GitHub Commit & Push
if: github.event_name != 'pull_request'
uses: actions-js/push@968f4695ca558093eadb24ad83cc5891f47e0cdc # v1.6
with:
amend: ${{ steps.dist_branch.outputs.exists == 'true' }}
author_email: ${{ secrets.GH_BOT_EMAIL }}
author_name: ${{ vars.GH_BOT_NAME }}
branch: dist
directory: dist
force: ${{ steps.dist_branch.outputs.exists == 'true' }}
github_token: ${{ secrets.GH_BOT_TOKEN }}
message: 'Update release assets'
- name: Prepare artifact
run: |
cd gh-pages-template
7z a ../build.zip .
cd ../dist
7z a ../build.zip . "-xr!.git"
- name: Upload artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: update
path: build.zip
if-no-files-found: error
include-hidden-files: true
retention-days: 1
call-jekyll-build:
needs: update
permissions:
contents: read
uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master
secrets:
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
with:
clean_gh_pages: true
extract_archive: 'build.zip'
gh_bot_name: ${{ vars.GH_BOT_NAME }}
site_artifact: 'update'
target_branch: 'gh-pages'