CHORE: Try to use commit -- once again #47
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: Deploy to GitHub Pages | |
on: | |
workflow_dispatch: | |
push: | |
branches: 'master' | |
permissions: | |
contents: write | |
jobs: | |
build_site: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
pull-requests: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
ref: ${{ github.head_ref }} | |
fetch-depth: 0 | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build project | |
env: | |
PUBLIC_FIREBASE_API_KEY: ${{ secrets.PUBLIC_FIREBASE_API_KEY }} | |
PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.PUBLIC_FIREBASE_AUTH_DOMAIN }} | |
PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.PUBLIC_FIREBASE_PROJECT_ID }} | |
PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.PUBLIC_FIREBASE_STORAGE_BUCKET }} | |
PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} | |
PUBLIC_FIREBASE_APP_ID: ${{ secrets.PUBLIC_FIREBASE_APP_ID }} | |
PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.PUBLIC_FIREBASE_MEASUREMENT_ID }} | |
run: | | |
pnpm run build | |
touch build/.nojekyll | |
- name: Fix permissions | |
run: | | |
chmod -c -R +rX "build/" | while read line; do | |
echo "::warning title=Invalid file permissions automatically fixed::$line" | |
done | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: github-pages | |
path: build | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
artifact_name: github-pages | |
- name: Force push gh-pages branch | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: build | |
clean: true | |
branch: gh-pages | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
- name: Commit generated files only | |
run: | | |
echo "> Start remove unused files..." | |
rm -rf .github/workflows .svelte-kit markdowns screenshoot scripts static src node_modules | |
rm -rf .all-contributorsrc .editorconfig .eslintignore .eslintrc.cjs .gitignore .kodiak.toml .npmrc .prettierignore .prettierrc package.json pnpm-lock.yaml postcss.config.js svelte.config.js tailwind.config.js tsconfig.json vite.config.ts | |
echo "> Copy build directory..." | |
cp -r build/. ./ | |
rm -rf build | |
echo "> Set git config..." | |
git config --local user.email "[email protected]" | |
git config --local user.name "Irfan Maulana" | |
echo "> Add and commit files..." | |
git add -A | |
git commit -m "[CI]: Auto Deploy 🚀" | |
echo "> Finish commit changes to repo" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
repository: mazipan-quran-offline/mazipan-quran-offline.github.io | |
force: true | |
github_token: ${{ secrets.PERSONAL_TOKEN }} | |
branch: master | |
directory: build |