Skip to content

Commit

Permalink
feat: enhance workflows (#28)
Browse files Browse the repository at this point in the history
* feat: cache dependencies

* feat: run on api sync

* fix: dependency cache and end cargo run gracefully
  • Loading branch information
adrrf authored Nov 20, 2024
1 parent 6201a4a commit ef27e3f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
- develop
pull_request:
branches:
branches:
- main
- develop

Expand All @@ -18,13 +18,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout ⬇️
uses: actions/checkout@v4.2.2
with:
show-progress: false

- name: Copy Config File 📄
run: cp config.yaml.example config.yaml

- name: Build 🛠️
run: cargo build --verbose
- name: Checkout ⬇️
uses: actions/checkout@v4.2.2
with:
show-progress: false

- name: Cache Dependencies 📦
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Copy Config File 📄
run: cp config.yaml.example config.yaml

- name: Build 🛠️
run: cargo build --verbose
18 changes: 17 additions & 1 deletion .github/workflows/sync-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cache Dependencies 📦
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Sync OpenAPI Specs 🔄
timeout-minutes: 2
run: |
mkdir -p docs
cp config.yaml.example config.yaml
./sync-openapi.sh
(cargo run &)
sleep 30
pkill -f cargo || true
- name: Commit and push changes 📤
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git add docs
git add .
git diff --quiet && git diff --staged --quiet || (git commit -m "chore: sync openapi specs🔄" && git push)
2 changes: 1 addition & 1 deletion openapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div id="swagger-ui"></div>
<script>
const ui = SwaggerUIBundle({
url: 'http://0.0.0.0:8080/docs/openapi.yaml', // Use self.url to dynamically insert the URL
url: 'http://0.0.0.0:8080/docs/openapi.yaml',
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
Expand Down

0 comments on commit ef27e3f

Please sign in to comment.