Build and release site to GitHub Pages #120492
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and release site to GitHub Pages | |
on: | |
schedule: | |
# daily build | |
- cron: '0 0 * * *' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
gh-pages-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# We need a personal access token to be able to push to a protected branch | |
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: Install Node.js modules | |
run: npm ci | |
- name: Run Tests | |
run: npm run test | |
- name: Build and push repositories json | |
env: | |
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "eg-oss-ci" | |
npm run build-repo-data | |
if git diff --quiet; then | |
echo "No changes to repositories data" | |
else | |
git add static/repos.json | |
git commit -m "Updated repos.json" | |
git push | |
fi | |
- name: Build and push blog posts json | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "eg-oss-ci" | |
npm run build-posts-data | |
if git diff --quiet; then | |
echo "No changes to blog posts data" | |
else | |
git add static/posts.json | |
git commit -m "Updated posts.json" | |
git push | |
fi | |
- name: Build site | |
run: npm run build | |
- name: Validate content of cname file | |
run: cat ./build/CNAME | grep opensource.expediagroup.com | |
- name: Release to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./build | |
user_name: eg-oss-ci | |
user_email: [email protected] |