Merge pull request #16364 from timvandermeij/github-pages
Introduce a GitHub Actions workflow for publishing the website
This commit is contained in:
commit
9eea9993df
63
.github/workflows/publish_website.yml
vendored
Normal file
63
.github/workflows/publish_website.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
name: Publish website
|
||||
on: [push]
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Use Node.js 18 LTS
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Install Gulp
|
||||
run: npm install -g gulp-cli
|
||||
|
||||
- name: Install other dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Build the website
|
||||
run: gulp web
|
||||
|
||||
- name: Archive the website
|
||||
shell: sh
|
||||
run: |
|
||||
chmod -c -R +rX "$INPUT_PATH" | while read line; do
|
||||
echo "::warning title=Invalid file permissions automatically fixed::$line"
|
||||
done
|
||||
tar \
|
||||
--dereference --hard-dereference \
|
||||
--directory "$INPUT_PATH" \
|
||||
-cvf "$RUNNER_TEMP/website.tar" \
|
||||
--exclude=.git \
|
||||
--exclude=.github \
|
||||
.
|
||||
env:
|
||||
INPUT_PATH: build/gh-pages
|
||||
|
||||
- name: Upload the website
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: github-pages
|
||||
path: ${{ runner.temp }}/website.tar
|
||||
retention-days: 1
|
||||
if-no-files-found: error
|
||||
|
||||
deploy:
|
||||
name: Deploy
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
permissions:
|
||||
pages: write # Required to deploy to GitHub Pages.
|
||||
id-token: write # Required to verify that the deployment originates from this workflow.
|
||||
|
||||
steps:
|
||||
- name: Deploy the website
|
||||
uses: actions/deploy-pages@v2
|
31
gulpfile.js
31
gulpfile.js
@ -68,7 +68,6 @@ const COMMON_WEB_FILES = [
|
||||
];
|
||||
const MOZCENTRAL_DIFF_FILE = "mozcentral.diff";
|
||||
|
||||
const REPO = "git@github.com:mozilla/pdf.js.git";
|
||||
const DIST_REPO_URL = "https://github.com/mozilla/pdfjs-dist";
|
||||
|
||||
const builder = require("./external/builder/builder.js");
|
||||
@ -2133,33 +2132,6 @@ gulp.task("wintersmith", function (done) {
|
||||
});
|
||||
});
|
||||
|
||||
function ghPagesGit(done) {
|
||||
const VERSION = getVersionJSON().version;
|
||||
const reason = process.env.PDFJS_UPDATE_REASON;
|
||||
|
||||
safeSpawnSync("git", ["init"], { cwd: GH_PAGES_DIR });
|
||||
safeSpawnSync("git", ["remote", "add", "origin", REPO], {
|
||||
cwd: GH_PAGES_DIR,
|
||||
});
|
||||
safeSpawnSync("git", ["add", "-A"], { cwd: GH_PAGES_DIR });
|
||||
safeSpawnSync(
|
||||
"git",
|
||||
[
|
||||
"commit",
|
||||
"-am",
|
||||
"gh-pages site created via gulpfile.js script",
|
||||
"-m",
|
||||
"PDF.js version " + VERSION + (reason ? " - " + reason : ""),
|
||||
],
|
||||
{ cwd: GH_PAGES_DIR }
|
||||
);
|
||||
safeSpawnSync("git", ["branch", "-m", "gh-pages"], { cwd: GH_PAGES_DIR });
|
||||
|
||||
console.log();
|
||||
console.log("Website built in " + GH_PAGES_DIR);
|
||||
done();
|
||||
}
|
||||
|
||||
gulp.task(
|
||||
"web",
|
||||
gulp.series(
|
||||
@ -2167,8 +2139,7 @@ gulp.task(
|
||||
"generic-legacy",
|
||||
"jsdoc",
|
||||
ghPagesPrepare,
|
||||
"wintersmith",
|
||||
ghPagesGit
|
||||
"wintersmith"
|
||||
)
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user