Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdan authored Sep 5, 2024
1 parent b9702cb commit 2825ffa
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@ on:
branches:
- main

env:
PYTHON_VERSION: '3.x'
MKDOCS_SITE_DIR: 'site'
DOCS_BRANCH: 'gh-pages'
DOCS_SUBDIR: 'ai-core-concepts'

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: ${{ env.PYTHON_VERSION }}

- name: Install MkDocs and dependencies
run: |
Expand All @@ -24,16 +31,35 @@ jobs:
- name: Build the MkDocs site
run: mkdocs build

- name: Generate GitHub App token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: ${{ secrets.INSTALLATION_ID }}

- name: Clone the Documentation Repo
run: |
git config --global user.name 'github-actions'
git config --global user.email 'actions@github.com'
git clone --branch gh-pages https://${{ secrets.ACCESS_TOKEN }}@github.com/acceleratescience/workshops.git workshops
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git clone --branch ${{ env.DOCS_BRANCH }} https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/acceleratescience/workshops.git temp_docs
- name: Deploy to Documentation Repo
run: |
rsync -av --delete ./site/ workshops/ai-core-concepts/
cd workshops
# Ensure the target directory exists
mkdir -p temp_docs/${{ env.DOCS_SUBDIR }}
# Sync the built site to the target directory
rsync -av --delete ${{ env.MKDOCS_SITE_DIR }}/ temp_docs/${{ env.DOCS_SUBDIR }}/
# Commit and push changes
cd temp_docs
git add .
git commit -m "Deploy ai-core-concepts to /ai-core-concepts"
git diff-index --quiet HEAD || git commit -m "Update ${{ env.DOCS_SUBDIR }} workshops"
git push
- name: Clean up
if: always()
run: |
rm -rf temp_docs

0 comments on commit 2825ffa

Please sign in to comment.