Skip to content

Commit 4e4cb81

Browse files
committed
Add new workflow to create update nightly PR for all Rust apps
1 parent 9f9bcd2 commit 4e4cb81

File tree

1 file changed

+97
-4
lines changed

1 file changed

+97
-4
lines changed
Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,103 @@
11
name: Update Rust Toolchain Nightly for all Rust apps
2+
23
on:
3-
workflow_dispatch:
4+
workflow_dispatch: # Allows manual trigger
5+
6+
env:
7+
NIGHTLY: 'nightly-2026-01-01' # Set desired nightly version here
8+
9+
permissions:
10+
contents: write # Required to push the new branch
11+
pull-requests: write # Required to create the PR
412

513
jobs:
6-
test:
7-
name: test
14+
# retrieve-rust-apps:
15+
# name: Retrieve Rust Apps
16+
# runs-on: ubuntu-latest
17+
# outputs:
18+
# rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }}
19+
# steps:
20+
# - name: Checkout repository
21+
# uses: actions/checkout@v4
22+
# with:
23+
# repository: LedgerHQ/ledger-device-rust-sdk
24+
# ref: 'master'
25+
# - name: Set up Python
26+
# uses: actions/setup-python@v4
27+
# with:
28+
# python-version: '3.x'
29+
# - name: Install ledgered
30+
# run: pip install ledgered
31+
# - name: Get all rust apps
32+
# id: get_rust_apps
33+
# run: |
34+
# python .github/workflows/get_rust_apps_repositories.py ${{ secrets.GITHUB_TOKEN }}
35+
# echo "rust_apps=$(cat rust_apps.json)" >> $GITHUB_OUTPUT
36+
update-toolchain:
37+
name: Create Update Rust Nightly Toolchain PR
38+
#needs: retrieve-rust-apps
839
runs-on: ubuntu-latest
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
app-name: ["app-boilerplate-rust"]
44+
#include: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }}
945
steps:
10-
- run: echo "This is a placeholder job to test the workflow dispatch."
46+
- name: Configure Git
47+
run: |
48+
git config --global user.name "github-actions[bot]"
49+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
- name: Checkout Repository
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0 # Fetch all history for branching
55+
repository: LedgerHQ/${{ matrix.app-name }}
56+
submodules: true
57+
path: ${{ matrix.app-name }}
58+
token: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Create Branch
61+
working-directory: ${{ matrix.app-name }}
62+
run: |
63+
git checkout -b update_nightly
64+
65+
- name: Modify rust-toolchain.toml
66+
working-directory: ${{ matrix.app-name }}
67+
run: |
68+
# Using sed for simple text replacement in CI
69+
# This replaces the line starting with channel = "..." with the new version
70+
sed -i 's/channel = ".*"/channel = "${{ env.NIGHTLY }}"/' rust-toolchain.toml
71+
72+
# Print for verification logs
73+
cat rust-toolchain.toml
74+
75+
- name: Commit and Push
76+
id: commit_and_push
77+
working-directory: ${{ matrix.app-name }}
78+
run: |
79+
# Check if there are changes before committing
80+
if [[ -n $(git status -s) ]]; then
81+
git add rust-toolchain.toml
82+
git commit -m "Update rust-toolchain to latest nightly"
83+
git push origin update_nightly --force
84+
echo "changes_pushed=true" >> $GITHUB_OUTPUT
85+
else
86+
echo "No changes detected."
87+
echo "changes_pushed=false" >> $GITHUB_OUTPUT
88+
fi
89+
90+
- name: Create Pull Request
91+
if: steps.commit_and_push.outputs.changes_pushed == 'true'
92+
working-directory: ${{ matrix.app-name }}
93+
env:
94+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
run: |
96+
# Create PR using GitHub CLI
97+
# The '|| true' prevents failure if a PR already exists
98+
gh pr create \
99+
--title "Update Rust Toolchain to Nightly" \
100+
--body "Automated PR to update the rust-toolchain.toml file to the latest nightly version." \
101+
--base main \
102+
--head update_nightly \
103+
--reviewer "${{ github.actor }}" || echo "PR might already exist"

0 commit comments

Comments
 (0)