Skip to content

Commit

Permalink
build: split ci into jobs
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Groleau <[email protected]>
Co-authored-by: Remy Clarke <[email protected]>
  • Loading branch information
3 people committed Sep 13, 2023
1 parent 018b8f2 commit 6b65125
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
41 changes: 32 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ permissions:
env:
RUST_BACKTRACE: 1
jobs:
ci:
environment: pull_request_deployment
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -51,21 +50,45 @@ jobs:
echo "modified files detected"
exit 1
fi
- id: get_output_dir
run: echo "output_dir=$(cargo run -- print-output-dir)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: build_output_dir
path: ${{ steps.get_output_dir.outputs.output_dir }}
outputs:
output_dir: ${{ steps.get_output_dir.outputs.output_dir }}

deploy-preview:
if: github.event_name == 'pull_request_target'
needs: build
environment: pull_request_deployment
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: build_output_dir
path: ${{ needs.build.outputs.output_dir }}
- id: deploy
if: github.event_name == 'pull_request_target'
run: |
npx vercel pull --yes --environment=preview --scope mobusoperandi --token=${{ secrets.VERCEL_TOKEN }}
URL=$(npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
echo "URL=$URL" >> $GITHUB_OUTPUT
- if: github.event_name == 'pull_request_target'
uses: thollander/actions-comment-pull-request@v2
- uses: thollander/actions-comment-pull-request@v2
with:
message: |
Branch deployed for review at:
${{ steps.deploy.outputs.URL }}
- id: get_output_dir
run: echo "OUTPUT_DIR=$(cargo run -- print-output-dir)" >> $GITHUB_OUTPUT
deploy-production:
if: github.ref == 'refs/heads/master'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: build_output_dir
path: ${{ needs.build.outputs.output_dir }}
- uses: JamesIves/github-pages-deploy-action@v4
if: github.ref == 'refs/heads/master'
with:
folder: ${{ steps.get_output_dir.outputs.OUTPUT_DIR }}
folder: ${{ needs.build.outputs.output_dir }}
4 changes: 3 additions & 1 deletion builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ use once_cell::sync::Lazy;
pub static OUTPUT_DIR: Lazy<Utf8PathBuf> = Lazy::new(|| {
[env!("CARGO_MANIFEST_DIR"), "..", ".vercel/output/static"]
.iter()
.collect()
.collect::<Utf8PathBuf>()
.canonicalize_utf8()
.unwrap()
});

0 comments on commit 6b65125

Please sign in to comment.