Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a GitHub Actions workflow for publishing the website #16364

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/publish_website.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 30 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -2133,42 +2132,14 @@ 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(
"generic",
"generic-legacy",
"jsdoc",
ghPagesPrepare,
"wintersmith",
ghPagesGit
"wintersmith"
)
);

Expand Down