Skip to content

Commit

Permalink
use workflow Context
Browse files Browse the repository at this point in the history
  • Loading branch information
neo773 committed Nov 29, 2024
1 parent 6811ae3 commit b8fac45
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Cargo Clippy
run: cargo +nightly clippy --all-features --workspace -- -D warnings
deploy:
if: github.event.pull_request.merged == true
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
name: Deploy to Shuttle
runs-on: ubuntu-latest
permissions:
Expand Down
16 changes: 14 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ shuttle-runtime = "0.49.0"
shuttle-axum = "0.39.0"
async-trait = "0.1"

[dev-dependencies]
gh-workflow = "*"

[build-dependencies]
gh-workflow = "0.5.1"
tonic-build = "0.11.0"
gh-workflow = "*"

[dev-dependencies]
gh-workflow = "0.5.1"
8 changes: 7 additions & 1 deletion tests/ci.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use gh_workflow::ctx::Context;
use gh_workflow::toolchain::Toolchain;
use gh_workflow::*;

Expand Down Expand Up @@ -47,7 +48,12 @@ fn generate() {

let deploy = Job::new("Deploy to Shuttle")
.permissions(Permissions::default().contents(Level::Write))
.cond(Expression::new("github.event.pull_request.merged == true"))
.cond(
Context::github()
.event_name()
.eq("push".into())
.and(Context::github().ref_().eq("refs/heads/main".into())),
)
.runs_on("ubuntu-latest")
.add_step(Step::checkout())
.add_step(
Expand Down

0 comments on commit b8fac45

Please sign in to comment.