A bunch of CI improvements #13
Workflow file for this run
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
name: CD | |
on: | |
push: | |
branches: [main] | |
pull_request: # TODO: Don't do this on PR's | |
workflow_dispatch: | |
jobs: | |
changes: | |
name: Detect changes | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
updater: ${{ steps.filter.outputs.updater }} | |
web: ${{ steps.filter.outputs.web }} | |
rust: ${{ steps.filter.outputs.rust }} | |
steps: | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
updater: | |
- 'apps/updater/**' | |
web: | |
- 'apps/web/**' | |
- 'packages/**' | |
- package.json | |
- pnpm-lock.yaml | |
rust: | |
- 'apps/mattrax/**' | |
- 'apps/mattraxd/**' | |
- 'apps/mttx/**' | |
- 'crates/**' | |
- Cargo.toml | |
- Cargo.lock | |
updater: | |
name: Updater | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.updater == 'true' }} | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy to Deno Deploy | |
uses: denoland/deployctl@v1 | |
with: | |
project: mattrax-updater | |
entrypoint: src/main.ts | |
root: apps/updater | |
web: | |
name: Web | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.web == 'true' }} | |
steps: | |
# TODO: Deploy `apps/web` as a *preview build* | |
- run: echo "Hello World" | |
rust: | |
name: Rust | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.updater == 'true' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
[ | |
aarch64-unknown-linux-gnu, | |
x86_64-unknown-linux-gnu, | |
aarch64-apple-darwin, | |
x86_64-apple-darwin, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: "true" | |
- name: OpenSSL | |
run: sudo apt-get install -y pkg-config libssl-dev | |
- name: Install Zig toolchain | |
uses: korandoru/setup-zig@v1 | |
with: | |
zig-version: 0.12.0 | |
- name: | |
Install 'cargo-zigbuild' | |
# The Rust cache action is not happy with `cargo bininstall` so we do a manual install. | |
run: | | |
curl -s https://api.github.com/repos/rust-cross/cargo-zigbuild/releases/latest \ | |
| grep "browser_download_url.*.x86_64-unknown-linux-musl.tar.gz\"" \ | |
| cut -d : -f 2,3 \ | |
| tr -d \" \ | |
| wget -qi - | |
tar -xf cargo-zigbuild-*.tar.gz | |
mv cargo-zigbuild /usr/local/bin | |
- name: Add '${{ matrix.target }}' target | |
run: rustup target add ${{ matrix.target }} | |
- name: Build | |
run: cargo zigbuild --locked --release --target ${{ matrix.target }} | |
# TODO: Upload to R2 | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
# TODO: https://stackoverflow.com/questions/69354003/github-action-job-fire-when-previous-job-skipped | |
needs: [rust, web] | |
steps: | |
- run: echo "Hello World" | |
# TODO: Trigger Rust deploy and wait for it to finish (so we know migrations have run) | |
# TODO: Promote web to be a production deploy |