From c7f1a71c632912f3c538cda9cd0df4b2087719be Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 2 Apr 2024 10:35:27 -0400 Subject: [PATCH] ci: On workflow_dispatch, update py-shiny module and deploy to gh-pages (#122) * Add `submodules-pull-shiny` target for Makefile * Add script to manually commit to main with the latest py-shiny version on GitHub * debug * update permissions to token * Pull latest posit-dev/py-shiny@9570af4 * Revert "Pull latest posit-dev/py-shiny@9570af4" This reverts commit ad155d90eba01dfe8781745a1cf6afb9b4308b1c. * Add workflow_run trigger to main job (that deploys to gh-pages) * Pull latest posit-dev/py-shiny@9570af4 * Revert "Pull latest posit-dev/py-shiny@9570af4" This reverts commit 133d07a9fb02e59ea6df0bec9e1994d792a88609. * Update test branch to `main` * Use `setup-python@v5` to avoid warning in GHA --- .github/workflows/build.yml | 12 ++++----- .github/workflows/update_shiny.yml | 43 ++++++++++++++++++++++++++++++ Makefile | 2 ++ 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/update_shiny.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cfe3fc5..d2c2fb85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,10 @@ on: branches: [main] release: types: [published] - + workflow_run: + workflows: [Update py-shiny submodule] + types: + - completed jobs: build: runs-on: ubuntu-latest @@ -22,7 +25,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -66,7 +69,6 @@ jobs: # path: playwright-report/ # retention-days: 30 - # ===================================================== # Publish to AWS for shinylive.io # ===================================================== @@ -90,7 +92,6 @@ jobs: aws s3 sync _shinylive s3://shinylive.io --delete aws cloudfront create-invalidation --distribution-id $AWS_CLOUDFRONT_DISTRIBUTION_ID --paths "/*" - # ===================================================== # Upload _shinylive/ artifact # ===================================================== @@ -100,7 +101,6 @@ jobs: with: path: "_shinylive/" - # ===================================================== # Publish to shinylive.io # ===================================================== @@ -119,7 +119,6 @@ jobs: # deployment. command: pages publish _shinylive/ --project-name=shinylive --commit-dirty=true --branch=main - # ===================================================== # Upload shinylive bundle on release # ===================================================== @@ -148,7 +147,6 @@ jobs: file_glob: true overwrite: true - # ===================================================== # Deploy GitHub Pages site # ===================================================== diff --git a/.github/workflows/update_shiny.yml b/.github/workflows/update_shiny.yml new file mode 100644 index 00000000..9257b5b5 --- /dev/null +++ b/.github/workflows/update_shiny.yml @@ -0,0 +1,43 @@ +name: Update py-shiny submodule + +on: + workflow_dispatch: + +jobs: + update-shiny: + name: Update py-shiny submodule + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Upgrade pip + run: python -m pip install --upgrade pip + + - name: Check out submodules + run: | + make submodules + + - name: Pull latest py-shiny + run: | + make submodules-pull + + - name: Build shinylive + run: | + make all + + - name: Set up git within GHA + uses: actions4git/setup-git@v1 + + - name: Commit and push changes + run: | + PY_SHINY_SHA=$(git -C packages/py-shiny rev-parse --short HEAD) + git add packages/py-shiny shinylive_lock.json && \ + git commit --message "Pull latest posit-dev/py-shiny@$PY_SHINY_SHA" && \ + git push origin HEAD:main diff --git a/Makefile b/Makefile index 048eb6ce..85287644 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,8 @@ submodules: ## Pull latest changes in git submodules submodules-pull: git submodule update --recursive --remote +submodules-pull-shiny: + git submodule update --remote packages/py-shiny ## Build everything _except_ the shinylive.tar.gz distribution file