Skip to content

Commit 909d2d1

Browse files
committed
Move site generation to a script
1 parent f92b2cf commit 909d2d1

File tree

4 files changed

+27
-58
lines changed

4 files changed

+27
-58
lines changed

.github/actions/deploy/Dockerfile

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/actions/deploy/action.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,29 @@ on:
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9+
environment:
10+
name: github-pages
911
steps:
1012
- name: Checkout master
1113
uses: actions/checkout@v4
12-
with: { fetch-depth: 0 }
13-
- name: Checkout gh-pages
14-
run: git worktree add -B gh-pages public remotes/origin/gh-pages
15-
- name: Clean previous
16-
run: |
17-
find public -mindepth 1 -maxdepth 1 '!' -name .git -exec rm -rf '{}' '+'
1814
- name: Build site
19-
uses: pdidev/pdidev.github.io/.github/actions/deploy@main
20-
with:
21-
output-directory: public
22-
gitlab-url: https://gitlab.maisondelasimulation.fr
23-
project-name: pdidev%2Fpdi
24-
- name: Add static data
25-
run: |
26-
find data -mindepth 1 -maxdepth 1 -exec cp -r '{}' public ';'
27-
- name: Add sitemap
28-
run: |
29-
./gen_sitemap public
30-
- name: Push
15+
env:
16+
CI_PAGES_TOKEN: ${{secrets.CI_PAGES_TOKEN}}
3117
run: |
32-
cd public
33-
git config user.name "${GITHUB_ACTOR}"
34-
git config user.email "${GITHUB_ACTOR}@noreply.example.com"
35-
git add -A .
36-
git commit -a -m "Update to match ${GITHUB_SHA} by ${GITHUB_EVENT_NAME} ${GITHUB_RUN_NUMBER}"
37-
git push -f
18+
./generate _site https://gitlab.maisondelasimulation.fr pdidev%2Fpdi
19+
find data -mindepth 1 -maxdepth 1 -exec cp -r '{}' _site ';'
20+
./gen_sitemap _site
21+
- name: Upload page artifact
22+
uses: actions/upload-pages-artifact@v3
23+
publish:
24+
needs: build
25+
permissions:
26+
pages: write
27+
id-token: write
28+
environment:
29+
name: github-pages
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Deploy to GitHub Pages
33+
id: deployment
34+
uses: actions/deploy-pages@v4

.github/actions/deploy/entrypoint.sh renamed to generate

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ then
88
fi
99

1010
DEPLOY_DIR="${1}"
11-
cd "${GITHUB_WORKSPACE}"
1211
mkdir -p "${DEPLOY_DIR}"
1312
cd "${DEPLOY_DIR}"
1413
DEPLOY_DIR="${PWD}"
@@ -48,15 +47,15 @@ EOF
4847
## GITLAB
4948
########################
5049
INERROR=true
51-
ALLTAGS="$(curl -fs "${GITLAB_URL}/api/v4/projects/${PROJECT_NAME}/repository/tags" | tr ',' '\n' | grep '"name"' | tr '"' ' ' | awk '{print $4}' | grep '^[0-9]*\.[0-9]*\.[0-9]*$' | sort -rVu)"
50+
ALLTAGS="$(curl -fsS "${GITLAB_URL}/api/v4/projects/${PROJECT_NAME}/repository/tags" | tr ',' '\n' | grep '"name"' | tr '"' ' ' | awk '{print $4}' | grep '^[0-9]*\.[0-9]*\.[0-9]*$' | sort -rVu)"
5251
for TAG_BASE in $(echo "${ALLTAGS}" | sed 's/^\([0-9]*\.[0-9]*\.\)[0-9]*$/\1/' | sort -rVu)
5352
do
5453
for TAG in $(echo "${ALLTAGS}" | fgrep "${TAG_BASE}" | sort -rVu)
5554
do
5655
cd "${WORK_DIR}"
5756
mkdir -p "${TAG}"
5857
cd "${TAG}"
59-
if curl -fso artifacts.zip "${GITLAB_URL}/api/v4/projects/${PROJECT_NAME}/jobs/artifacts/${TAG}/download?job=pages"
58+
if curl -fsSo artifacts.zip "${GITLAB_URL}/api/v4/projects/${PROJECT_NAME}/jobs/artifacts/${TAG}/download?job=pages"
6059
then
6160
INERROR=false
6261
STAG="$(echo "${TAG}" | sed 's/\.[0-9]*$//')"
@@ -97,15 +96,15 @@ fi
9796
## GITHUB
9897
########################
9998
#INERROR=true
100-
#ALLTAGS="$(curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -fs "https://api.github.com/repos/${PROJECT_NAME}/tags" | tr ',' '\n' | grep '"name"' | tr '"' ' ' | awk '{print $3}' | grep '^[0-9]*\.[0-9]*\.[0-9]*-gh$' | sort -rVu)"
99+
#ALLTAGS="$(curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -fsS "https://api.github.com/repos/${PROJECT_NAME}/tags" | tr ',' '\n' | grep '"name"' | tr '"' ' ' | awk '{print $3}' | grep '^[0-9]*\.[0-9]*\.[0-9]*-gh$' | sort -rVu)"
101100
#for TAG_BASE in $(echo "${ALLTAGS}" | sed 's/^\([0-9]*\.[0-9]*\.\)[0-9]*-gh$/\1/' | sort -rVu)
102101
#do
103102
# for TAG in $(echo "${ALLTAGS}" | fgrep "${TAG_BASE}" | sort -rVu)
104103
# do
105104
# cd "${WORK_DIR}"
106105
# mkdir -p "${TAG}"
107106
# cd "${TAG}"
108-
# if curl -Lfso artifacts.zip "https://api.github.com/repos/${PROJECT_NAME}/zipball/refs/tags/${TAG}"
107+
# if curl -LfsSo artifacts.zip "https://api.github.com/repos/${PROJECT_NAME}/zipball/refs/tags/${TAG}"
109108
# then
110109
# INERROR=false
111110
# STAG="$(echo "${TAG}" | sed 's/\.[0-9]*$//')"
@@ -146,8 +145,8 @@ fi
146145
mkdir -p "${WORK_DIR}/main"
147146
cd "${WORK_DIR}/main"
148147

149-
DOWNLOAD_URL=$(curl -fs -H "Authorization: Bearer ${CI_PAGES_TOKEN}" https://api.github.com/repos/pdidev/pdi/actions/artifacts | jq -r '.artifacts | .[] | select(.workflow_run.head_branch=="main") | .archive_download_url')
150-
curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -Lfso artifacts.zip "${DOWNLOAD_URL}"
148+
DOWNLOAD_URL=$(curl -fsS -H "Authorization: Bearer ${CI_PAGES_TOKEN}" https://api.github.com/repos/pdidev/pdi/actions/artifacts | jq -r '.artifacts | .[] | map(select(.workflow_run.head_branch=="main")) | sort_by(.created_at) | last | .archive_download_url ')
149+
curl -H "Authorization: Bearer ${CI_PAGES_TOKEN}" -LfsSo artifacts.zip "${DOWNLOAD_URL}"
151150
unzip -o -d public artifacts.zip
152151
rm artifacts.zip
153152
if [ -d "public/main" ]

0 commit comments

Comments
 (0)