refactor: update artifact handling in deployment workflow #13
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: Build Docusaurus Docs | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
pull-docs: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout Main Repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Make fetch_docs.sh Executable | |
run: chmod +x ${{ github.workspace }}/scripts/fetch_docs.sh | |
- name: Fetch All Docs | |
run: ${{ github.workspace }}/scripts/fetch_docs.sh | |
- name: Debug | |
run: | | |
ls -R ${{ github.workspace }}/MainDocs | |
ls | |
- name: Upload Docs Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs-raw | |
path: ${{ github.workspace }}/MainDocs/docs/ | |
commit-docs: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: pull-docs | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
working-directory: ${{ github.workspace }}/MainDocs | |
- name: Download Built Docs Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs-raw | |
path: ${{ github.workspace }}/MainDocs/docs/ | |
- name: Check for Changes | |
run: | | |
git status | |
ls -R ${{ github.workspace }}/MainDocs/docs | |
working-directory: ${{ github.workspace }}/MainDocs | |
- name: Add Changes | |
run: git add . | |
working-directory: ${{ github.workspace }}/MainDocs | |
- name: Commit Changes | |
run: | | |
git commit -m "Update Docusaurus docs" || echo "No changes to commit" | |
working-directory: ${{ github.workspace }}/MainDocs | |
- name: Configure Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/pvarki/Docusaurus-docs.git | |
- name: Pull Latest Changes | |
run: git pull --rebase origin main | |
- name: Push Changes | |
run: git push origin main | |
working-directory: ${{ github.workspace }}/MainDocs | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: pull-docs | |
steps: | |
- name: Checkout Documentation Repo | |
uses: actions/checkout@v4 | |
- name: Build Docker Image | |
run: | | |
docker build -t pvarki/pvarkidocs:latest -f dockerfile . | |
- name: Log in to Docker Hub | |
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
- name: Push Docker Image to Docker Hub | |
run: | | |
docker push pvarki/pvarkidocs:latest | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Download Built Docs Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs-raw | |
path: ${{ github.workspace }}/MainDocs/build | |
- name: Install Dependencies | |
run: npm ci | |
working-directory: ${{ github.workspace }}/MainDocs | |
- name: Build Docusaurus Site | |
run: npm run build | |
working-directory: ${{ github.workspace }}/MainDocs | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ${{ github.workspace }}/MainDocs/build |