nojekyl #3
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: publish_to_pages | |
on: | |
push: | |
branches: | |
- "main" | |
- "jsonld_IV" | |
jobs: | |
push2production: | |
runs-on: ubuntu-latest | |
env: | |
API_KEY: ${{ secrets.API_KEY }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH: ${{ github.ref_name }} | |
permissions: | |
actions: write | |
checks: write | |
contents: write | |
deployments: write | |
id-token: write | |
packages: write | |
pages: write | |
pull-requests: write | |
repository-projects: write | |
statuses: write | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch the complete commit history | |
- name: Set up Git | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "Daniel Ellis" | |
git config credential.helper store | |
git config --global user.email "[email protected]" | |
git config --global user.name "Daniel Ellis" | |
git config --global push.default current | |
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV | |
shell: bash | |
- name: create symbolic link without extension | |
id: push_to_production | |
run: | | |
# Check if production branch exists; if not, create an empty branch | |
if ! git show-ref --verify --quiet refs/heads/production; then | |
# Create an empty orphan branch named production | |
git checkout --orphan production | |
git rm -rf . | |
# Create a .nojekyll file to prevent GitHub Pages from processing with Jekyll | |
touch .nojekyll | |
git add .nojekyll | |
git commit -m "Add .nojekyll to production branch" | |
else | |
git checkout production | |
fi | |
# Checkout the specified branch's data_descriptors directory into production | |
git checkout "${BRANCH}" -- data_descriptors | |
mv data_descriptors docs | |
# copy the 404 code. | |
cp 404.html docs/404.html | |
# Find all .json files and create symbolic links without the .json extension | |
find . -type f -name "*.json" -exec sh -c 'ln -s "$0" "${0%.json}"' {} \; | |
# Stage all changes, commit, and push to production branch | |
git add -A | |
git commit -m "production push" | |
git push --force origin production |