Skip to content

Commit 490e0d7

Browse files
authored
Merge pull request #158 from johnmhoran/154-update-workflows-add-redirects
154 update workflows add redirects
2 parents 347954f + 1188a8f commit 490e0d7

8 files changed

Lines changed: 330 additions & 109 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build Docusaurus Site (Manual)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target:
7+
description: "Build target (affects baseUrl config)"
8+
required: true
9+
default: "dreamhost"
10+
type: choice
11+
options:
12+
- dreamhost
13+
- gh
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build:
20+
name: Build site
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
25+
26+
- name: Setup Node
27+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
28+
with:
29+
node-version: 20
30+
cache: npm
31+
cache-dependency-path: website/package-lock.json
32+
33+
- name: Install dependencies
34+
run: |
35+
cd website
36+
npm ci
37+
38+
- name: Build Docusaurus site
39+
env:
40+
DEPLOY_TARGET: ${{ inputs.target }}
41+
run: |
42+
cd website
43+
npm run build
44+
45+
- name: Upload build artifact
46+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
47+
with:
48+
name: docusaurus-build
49+
path: website/build
50+
# JMH -- TBD:
51+
# retention-days: 7
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build & Deploy Docusaurus Site
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
pull_request:
8+
branches: [ main ]
9+
10+
workflow_dispatch:
11+
inputs:
12+
target:
13+
description: "Deploy target"
14+
required: true
15+
default: "gh"
16+
type: choice
17+
options:
18+
- gh
19+
- dreamhost
20+
21+
permissions:
22+
contents: read
23+
pages: write
24+
id-token: write
25+
26+
jobs:
27+
build:
28+
name: Build site
29+
runs-on: ubuntu-latest
30+
31+
outputs:
32+
deploy_target: ${{ steps.set-target.outputs.target }}
33+
34+
steps:
35+
- name: Checkout repo
36+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
37+
38+
- name: Set deploy target
39+
id: set-target
40+
run: |
41+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
42+
echo "target=${{ inputs.target }}" >> $GITHUB_OUTPUT
43+
else
44+
echo "target=gh" >> $GITHUB_OUTPUT
45+
fi
46+
47+
- name: Setup Node
48+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
49+
with:
50+
node-version: 20
51+
cache: npm
52+
cache-dependency-path: website/package-lock.json
53+
54+
- name: Install dependencies
55+
run: |
56+
cd website
57+
npm ci
58+
59+
- name: Build Docusaurus site
60+
env:
61+
DEPLOY_TARGET: ${{ steps.set-target.outputs.target }}
62+
run: |
63+
cd website
64+
npm run build
65+
66+
- name: Upload build artifact
67+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
68+
with:
69+
name: docusaurus-build
70+
path: website/build
71+
72+
73+
deploy-gh-pages:
74+
name: Deploy to GitHub Pages
75+
needs: build
76+
if: |
77+
needs.build.outputs.deploy_target == 'gh' &&
78+
github.event_name != 'pull_request'
79+
runs-on: ubuntu-latest
80+
81+
environment:
82+
name: github-pages
83+
84+
steps:
85+
- name: Download build artifact
86+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
87+
with:
88+
name: docusaurus-build
89+
path: build
90+
91+
- name: Upload Pages artifact
92+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
93+
with:
94+
path: build
95+
96+
- name: Deploy to GitHub Pages
97+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e #v4.0.5
98+
99+
100+
deploy-dreamhost:
101+
name: Deploy to DreamHost
102+
needs: build
103+
if: |
104+
needs.build.outputs.deploy_target == 'dreamhost' &&
105+
github.event_name != 'pull_request'
106+
runs-on: ubuntu-latest
107+
108+
steps:
109+
- name: Download build artifact
110+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
111+
with:
112+
name: docusaurus-build
113+
path: build
114+
115+
- name: Setup SSH
116+
run: |
117+
mkdir -p ~/.ssh
118+
echo "${{ secrets.DREAMHOST_SSH_KEY }}" > ~/.ssh/id_rsa
119+
chmod 600 ~/.ssh/id_rsa
120+
ssh-keyscan -H ${{ secrets.DREAMHOST_HOST }} >> ~/.ssh/known_hosts
121+
122+
- name: Deploy via rsync
123+
run: |
124+
rsync -avz --delete build/ \
125+
${{ secrets.DREAMHOST_USER }}@${{ secrets.DREAMHOST_HOST }}:${{ secrets.DREAMHOST_PATH }}/

.github/workflows-archive/deploy.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Update Releases Feed
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# - cron: "15 * * * *" # every hour at :15
7+
- cron: "15 9 * * *" # every day at 09:15 UTC
8+
9+
jobs:
10+
update:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write # needed to commit updates to releases.json
14+
15+
strategy:
16+
max-parallel: 1
17+
matrix:
18+
repo:
19+
- aboutcode-org/aboutcode-toolkit
20+
- aboutcode-org/ai-gen-code-search
21+
- aboutcode-org/binary-inspector
22+
- aboutcode-org/commoncode
23+
- aboutcode-org/container-inspector
24+
- aboutcode-org/debian-inspector
25+
- aboutcode-org/dejacode
26+
- aboutcode-org/dependency-inspector
27+
- aboutcode-org/elf-inspector
28+
- aboutcode-org/extractcode
29+
- aboutcode-org/federatedcode
30+
- aboutcode-org/fetchcode
31+
- aboutcode-org/go-inspector
32+
- aboutcode-org/license-expression
33+
- aboutcode-org/matchcode-toolkit
34+
- aboutcode-org/nuget-inspector
35+
- aboutcode-org/plugincode
36+
- aboutcode-org/purldb
37+
- aboutcode-org/purl-validator
38+
- aboutcode-org/purlvalidator-go
39+
- aboutcode-org/pygmars
40+
- aboutcode-org/python-inspector
41+
- aboutcode-org/rust-inspector
42+
- aboutcode-org/saneyaml
43+
- aboutcode-org/scancode.io
44+
- aboutcode-org/scancode-plugins
45+
- aboutcode-org/scancode-toolkit
46+
- aboutcode-org/scancode-workbench
47+
- aboutcode-org/source-inspector
48+
- aboutcode-org/typecode
49+
- aboutcode-org/univers
50+
- aboutcode-org/vulnerablecode
51+
- aboutcode-org/www.aboutcode.org
52+
# Add more repos here
53+
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GH_REPO_POLLING }}
56+
57+
steps:
58+
# 1 Checkout the target repo (Repo B)
59+
- name: Checkout repository
60+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
61+
with:
62+
ref: main
63+
fetch-depth: 0
64+
token: ${{ secrets.GH_REPO_POLLING }}
65+
66+
# 2 Debug: show which repo is being processed
67+
- name: Debug - current repo
68+
run: echo "Processing ${{ matrix.repo }}"
69+
70+
# 3 Fetch the latest release from the current source repo
71+
- name: Fetch latest release
72+
run: |
73+
REPO=${{ matrix.repo }}
74+
curl -s -H "Accept: application/vnd.github+json" \
75+
https://api.github.com/repos/$REPO/releases/latest \
76+
-o release.json || echo '{}' > release.json
77+
78+
# 4 Update releases.json in website/static cl
79+
- name: Update releases.json
80+
env:
81+
REPO: ${{ matrix.repo }}
82+
run: |
83+
TMP=$(mktemp)
84+
FILTER=$(mktemp --suffix=.jq)
85+
mkdir -p website/static
86+
if [ ! -f website/static/releases.json ]; then
87+
echo "[]" > website/static/releases.json
88+
fi
89+
printf '%s\n' \
90+
'$existing[0] +' \
91+
'[ $release[0] | {' \
92+
' repo: (if .name==null then "" else .name end),' \
93+
' repo_slug: env.REPO,' \
94+
' repo_url: ("https://github.com/" + env.REPO),' \
95+
' tag: (if .tag_name==null then "" else .tag_name end),' \
96+
' tag_url: (if .html_url==null then "" else .html_url end),' \
97+
' published_at: (if .published_at==null then "" else .published_at end),' \
98+
' releases_page_url: ("https://github.com/" + env.REPO + "/releases"),' \
99+
' compare_url: ("https://github.com/" + env.REPO + "/compare/" + (if .tag_name==null then "" else .tag_name end) + "...main"),' \
100+
' commits_since: 0,' \
101+
' prerelease: .prerelease,' \
102+
' author: (if .author==null then "" else .author.login end)' \
103+
'}' \
104+
'] | sort_by(.published_at) | reverse | unique_by(.repo_url) | sort_by(.published_at) | reverse' \
105+
> "$FILTER"
106+
jq -n \
107+
--slurpfile existing website/static/releases.json \
108+
--slurpfile release release.json \
109+
-f "$FILTER" > "$TMP"
110+
mv "$TMP" website/static/releases.json
111+
rm -f release.json "$FILTER"
112+
shell: bash
113+
114+
# 5 Commit & push changes if releases.json changed
115+
- name: Commit and push if changed
116+
run: |
117+
git config user.name "AboutCode Automation"
118+
git config user.email "automation@aboutcode.org"
119+
git add website/static/releases.json
120+
git commit -m "$(echo -e "Update releases for ${{ matrix.repo }}\n\nSigned-off-by: AboutCode Automation <automation@aboutcode.org>")" || exit 0
121+
git pull --rebase origin main
122+
git push
123+
shell: bash

0 commit comments

Comments
 (0)