refactor: update GitHub Actions workflow to download articles to a te… #161
This file contains hidden or 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: Deploy SvelteKit to GitHub Pages | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install gdown | |
run: pip install gdown | |
- name: Download folder | |
# Use the secret from GitHub repository settings | |
run: | | |
mkdir -p tmp/ | |
gdown --folder ${{ secrets.GDRIVE_FOLDER_ID }} -O tmp/ | |
- name: Move articles to correct location | |
run: | | |
mkdir -p src/routes/posts/mdarticles/[slug]/ | |
mv tmp/mdarticles/* src/routes/posts/mdarticles/[slug]/ | |
rmdir tmp | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm install | |
- name: Build the site | |
run: npm run build | |
env: | |
NODE_ENV: production | |
- name: Create .nojekyll file | |
# Prevents GitHub Pages from running built files through Jekyll | |
run: touch build/.nojekyll | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: './build' | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |