Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: split ci into jobs #220

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
7 changes: 4 additions & 3 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use camino::Utf8PathBuf;
use once_cell::sync::Lazy;

pub static OUTPUT_DIR: Lazy<Utf8PathBuf> = Lazy::new(|| {
[env!("CARGO_MANIFEST_DIR"), "..", ".vercel/output/static"]
.iter()
.collect()
Utf8PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.join(".vercel/output/static")
});