Skip to content

nojekyl

nojekyl #30

Workflow file for this run

name: publish_to_pages
on:
push:
branches:
- "main"
- "jsonld_IV"
# workflow_run:
# workflows: ["Build", "Test"] # List the names of the workflows it should wait for
# types:
# - completed # Trigger only when the specified workflows complete
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 .
# curl command here
echo "curl command here"
touch 404.html
# 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"
# # Make sure the publish workflow exists
# mkdir -p .github/workflows
# Check out the static.yml file from the source branch to the production branch
git checkout "${BRANCH}" -- .github/workflows/static.yml
else
git checkout production
rm -rf docs
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 data_descriptors/404.html
cp .nojekyll data_descriptors/.nojekyll
# Find all .json files and create symbolic links without the .json extension
# return to copys as artifacts do not handle symlinks
find . -type f -name "*.json" -exec sh -c 'cp "$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
# Trigger the second workflow using the GitHub Actions API
- name: Trigger Production Workflow
if: ${{ success() }} # Only trigger if previous steps were successful
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run static.yml --ref production
# curl -X POST -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer $GITHUB_TOKEN" \
# https://api.github.com/repos/${{ github.repository }}/actions/workflows/static.yml/dispatches \
# -d '{"ref":"production"}'