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
# Deploy branch is followed by Posit Connect | |
name: Update Requirements and Manifest on Deploy Branch | |
on: | |
push: | |
branches: | |
- main # Trigger when pushing to main | |
jobs: | |
update-branches: | |
env: | |
UV_SYSTEM_PYTHON: true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main | |
uses: actions/checkout@v4 | |
- name: Setup uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
- name: Install yq | |
run: sudo apt-get update && sudo apt-get install -y yq | |
- name: Read deployment mode from YAML file | |
run: | | |
export MODE=$(cat deploy_mode.yaml | yq '.mode') | |
echo "mode=$MODE" >> $GITHUB_ENV | |
- name: Print the deployment mode | |
run: echo "The deployment mode is ${{ env.mode }}" | |
- name: Generate requirements.txt with `uv` | |
run: uv export --no-hashes -o requirements.txt | |
- name: Generate rsconnect-python manifest.json | |
run: uvx --from rsconnect-python rsconnect write-manifest shiny . --entrypoint shinylims.app:app | |
- name: Commit and push changes based on mode | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add requirements.txt manifest.json | |
git commit -m "Update requirements and manifest" || echo "No changes to commit" | |
if [ "${{ env.mode }}" == "test" ]; then | |
git push origin --force HEAD:test_deploy # Push to test branch | |
elif [ "${{ env.mode }}" == "prod" ]; then | |
git push origin --force HEAD:deploy # Push to deploy branch | |
elif [ "${{ env.mode }}" == "both" ]; then | |
git push origin --force HEAD:test_deploy # Push to test branch | |
git push origin --force HEAD:deploy # Push to deploy branch |