Install latest Gleam in GH Action #174
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
| on: [push, workflow_dispatch] | |
| name: CI | |
| jobs: | |
| build-backend: | |
| name: quanweb | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| BUILD_TARGET: [release] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get backend changes | |
| id: changed-backend | |
| uses: tj-actions/[email protected] | |
| with: | |
| files: | | |
| **.rs | |
| **.yml | |
| **.toml | |
| Cargo.lock | |
| files_ignore: | | |
| admin | |
| ladmin | |
| # Our backend binary needs to embed the frontend built files. | |
| - uses: oven-sh/setup-bun@v2 | |
| if: steps.changed-backend.outputs.any_changed == 'true' | |
| - name: Build binary | |
| if: steps.changed-backend.outputs.any_changed == 'true' | |
| run: cargo build --profile ${{ matrix.BUILD_TARGET }} --all-features | |
| - name: Archive built files | |
| if: steps.changed-backend.outputs.any_changed == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Built binaries | |
| path: target/${{ matrix.BUILD_TARGET }}/quanweb | |
| build-ladmin-app: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ladmin | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get ladmin app changes | |
| id: changed-ladmin-app | |
| uses: tj-actions/[email protected] | |
| with: | |
| files: | | |
| ladmin/** | |
| **.yml | |
| - uses: oven-sh/setup-bun@v2 | |
| if: ${{ steps.changed-ladmin-app.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }} | |
| - uses: erlef/setup-beam@v1 | |
| if: ${{ steps.changed-ladmin-app.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }} | |
| with: | |
| otp-version: latest | |
| gleam-version: latest | |
| rebar3-version: latest | |
| # elixir-version: "1" | |
| - name: Add WASM target for Rust | |
| if: ${{ steps.changed-ladmin-app.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }} | |
| run: rustup target add wasm32-unknown-unknown | |
| - name: Download Gleam dependencies | |
| if: ${{ steps.changed-ladmin-app.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }} | |
| run: gleam deps download | |
| - name: Install JS dependencies | |
| if: ${{ steps.changed-ladmin-app.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }} | |
| run: bun i | |
| - name: Build ladmin app | |
| if: ${{ steps.changed-ladmin-app.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }} | |
| run: bun run --bun build | |
| - name: Upload Build Artifact | |
| if: ${{ steps.changed-ladmin-app.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ladmin-built | |
| path: ladmin/dist | |
| deploy-ladmin-app: | |
| runs-on: ubuntu-latest | |
| needs: [build-ladmin-app] | |
| if: github.ref == 'refs/heads/main' | |
| env: | |
| ANSIBLE_HOST_KEY_CHECKING: False | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Download Build Artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: ladmin-built | |
| path: ladmin-built | |
| id: download_step | |
| continue-on-error: true | |
| - name: Install Cowsay | |
| # Ansible is already installed by GitHub | |
| run: sudo apt-get install cowsay | |
| if: steps.download_step.outcome == 'success' | |
| - name: Install SSH priv key | |
| uses: webfactory/[email protected] | |
| with: | |
| ssh-private-key: ${{ secrets.ANSIBLE_SSH_PRIVATE_KEY }} | |
| if: steps.download_step.outcome == 'success' | |
| - name: Run Ansible playbook | |
| run: ansible-playbook -i Deployment/Ansible/inventory.yml Deployment/Ansible/playbook.yml --limit prod -u ${{ vars.SERVER_USERNAME }} | |
| if: steps.download_step.outcome == 'success' | |