remove test action #22
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
| # Deploys a quarto static site -- Intended to be called from another workflow e.g. | ||
| # uses: TimChild/webserver-template/deploy-quarto-static-site@main | ||
| # with: | ||
| # vps-ip: ${{ secrets.DROPLET_IP }} | ||
| # ... | ||
| name: Deploy Quarto Site | ||
| on: | ||
| workflow-call: | ||
| inputs: | ||
| vps-ip: | ||
| description: "The IP address of the VPS that is set up as a webserver" | ||
| required: true | ||
| type: string | ||
| site-name: | ||
| description: "The name of the site to deploy (same as when initializing the site, usually a single word)" | ||
| required: true | ||
| type: string | ||
| ssh-user: | ||
| description: "The user to connect to the VPS as (defaults to 'webadmin')" | ||
| default: "webadmin" | ||
| required: false | ||
| type: string | ||
| uses-python: | ||
| description: "Whether the site uses Python for generating content" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| uses-r: | ||
| description: "Whether the site uses R for generating content" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| secrets: | ||
| ssh-private-key: | ||
| description: "The private ssh key that grants access to the VPS" | ||
| required: true | ||
| type: string | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Check variables set | ||
| # Make it easier to see when environment setup is incorrect | ||
| run: | | ||
| if [ -z "${{ secrets.ssh-private-key }}" ]; then | ||
| echo "ssh-private-key is not set" | ||
| exit 1 | ||
| fi | ||
| if [ -z "${{ inputs.vps-ip }}" ]; then | ||
| echo "vps-ip is not set" | ||
| exit 1 | ||
| fi | ||
| if [ -z "${{ inputs.site-name }}" ]; then | ||
| echo "site-name is not set" | ||
| exit 1 | ||
| fi | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| - name: Setup static site builder (e.g. Quarto) | ||
| uses: quarto-dev/quarto-actions/setup@v2 | ||
| ### Install Python dependencies (to run any python for generating quarto content) | ||
| # Note: assumes using `uv` for dependency management | ||
| - name: Install uv | ||
| if: ${{ inputs.uses-python }} | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| enable-cache: true | ||
| version: "0.6.x" | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 # Use official because GH caches it | ||
| with: | ||
| python-version-file: "pyproject.toml" | ||
| - name: Install dependencies and activate virtual environment | ||
| run: uv sync | ||
| ### Install R dependencies (to run any R for generating quarto content) | ||
| # Note: This is untested (I don't use R, so don't know if this is correct) | ||
| - name: Setup R | ||
| if: ${{ inputs.uses-r }} | ||
| uses: r-lib/actions/setup-r@v1 | ||
| with: | ||
| r-version: "4.1" | ||
| ############ | ||
| - name: Build static site files | ||
| uses: quarto-dev/quarto-actions/render@v2 | ||
| - name: Send static files to server | ||
| uses: appleboy/[email protected] | ||
| with: | ||
| host: ${{ inputs.vps-ip }} | ||
| username: ${{ inputs.ssh-user }} | ||
| key: ${{ secrets.ssh-private-key }} | ||
| port: 22 | ||
| source: ./_site/ # This is the default build directory for Quarto | ||
| target: sites/${{ inputs.site-name }}/static/ | ||
| strip_components: 2 | ||
| overwrite: true | ||
| - name: Update frontend files on server | ||
| uses: appleboy/[email protected] | ||
| with: | ||
| host: ${{ inputs.vps-ip }} | ||
| username: ${{ inputs.ssh-user }} | ||
| key: ${{ secrets.ssh-private-key }} | ||
| # Note: This script is present on the server from the webserver setup | ||
| script: | | ||
| ./scripts/webserver-update-static-files.sh | ||