Skip to content

Commit c42acb0

Browse files
Toying around with slash commands
1 parent bc88e82 commit c42acb0

File tree

5 files changed

+107
-32
lines changed

5 files changed

+107
-32
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Prepare CI Rust environment"
2+
description: "Installs rust, protoc, just, some other stuff too"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Install Rust toolchain
7+
uses: actions-rust-lang/setup-rust-toolchain@v1
8+
with:
9+
components: clippy
10+
rustflags: ""
11+
cache: false
12+
13+
- name: Setup Rust Caching
14+
uses: WarpBuilds/rust-cache@v2 # a fork of Swatinem/rust-cache@v2 that uses warpbuild cache
15+
with:
16+
cache-on-failure: "true"
17+
18+
- name: Install cargo-hakari
19+
uses: taiki-e/install-action@v2
20+
with:
21+
tool: cargo-hakari
22+
23+
- name: Disable hakari
24+
run: cargo hakari disable
25+
26+
- name: Install protoc
27+
uses: ./.github/actions/install-protoc
28+
29+
- name: Install nextest
30+
uses: taiki-e/install-action@v2
31+
with:
32+
33+
34+
- name: Setup just
35+
uses: extractions/setup-just@v3
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,38 +51,8 @@ jobs:
5151

5252
- uses: actions/checkout@v4
5353

54-
- name: Install Rust toolchain
55-
uses: actions-rust-lang/setup-rust-toolchain@v1
56-
with:
57-
components: clippy
58-
rustflags: ""
59-
cache: false
60-
61-
- name: Setup Rust Caching
62-
uses: WarpBuilds/rust-cache@v2 # a fork of Swatinem/rust-cache@v2 that uses warpbuild cache
63-
with:
64-
cache-on-failure: "true"
65-
66-
- name: Install cargo-hakari
67-
uses: taiki-e/install-action@v2
68-
with:
69-
tool: cargo-hakari
70-
71-
- name: Disable hakari
72-
run: cargo hakari disable
73-
74-
- name: Install protoc
75-
uses: ./.github/actions/install-protoc
76-
77-
- name: Install nextest
78-
uses: taiki-e/install-action@v2
79-
with:
80-
81-
82-
- name: Setup just
83-
uses: extractions/setup-just@v3
84-
env:
85-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
- name: Setup CI environment
55+
uses: ./.github/actions/rust-env-setup
8656

8757
- name: Check Cargo.lock file is updated
8858
run: cargo update -w --locked
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Fmt slash command
2+
on:
3+
repository_dispatch:
4+
types: [fmt]
5+
jobs:
6+
pytest:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
with:
11+
token: ${{ secrets.PAT }}
12+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
13+
ref: ${{ steps.vars.outputs.branch }}
14+
15+
- name: Setup CI environment
16+
uses: ./.github/actions/rust-env-setup
17+
18+
- name: Run format
19+
run: just fmt
20+
21+
- name: Commit and push changes (if any)
22+
shell: bash
23+
env:
24+
CI_COMMIT_MESSAGE: Update template
25+
CI_COMMIT_AUTHOR: github-actions[bot]
26+
CI_COMMIT_EMAIL: [email protected]
27+
run: |
28+
cd destination
29+
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
30+
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
31+
if [[ `git status --porcelain --untracked-files=no` ]]; then
32+
# Changes
33+
git add .
34+
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
35+
git push
36+
else
37+
# No changes
38+
echo "no changes to the destination"
39+
exit 0
40+
fi
41+
42+
# Add reaction to the comment
43+
- name: Add reaction
44+
uses: peter-evans/create-or-update-comment@v4
45+
with:
46+
token: ${{ secrets.PAT }}
47+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
48+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
49+
reactions: hooray
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Slash Command Dispatch
2+
on:
3+
issue_comment:
4+
types: [created]
5+
jobs:
6+
slashCommandDispatch:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Slash Command Dispatch
10+
uses: peter-evans/slash-command-dispatch@v4
11+
with:
12+
token: ${{ secrets.PAT }}
13+
commands: |
14+
fmt
15+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: rust-env-setup.yml
2+
on:
3+
4+
jobs:

0 commit comments

Comments
 (0)