Skip to content

Commit c576470

Browse files
committed
Bug 1932096 - Create a GitHub action cron job to periodiaclly update in-tree data dumps
We want to keep the in-tree remote-settings dumps up to date. For this, a GitHub Actions workflow seems to be the easiest way for now. The workflow will check once a week if there is new data (through the `cargo remote-settings dump-sync` command). And commit any changes to a new branch and open a PR against main.
1 parent 4389742 commit c576470

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Update Remote Settings Dumps
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 0" # Run weekly on Sunday at midnight
6+
workflow_dispatch: # Allow manual trigger
7+
inputs:
8+
base_branch:
9+
description: 'Base branch'
10+
required: true
11+
default: 'main'
12+
13+
jobs:
14+
update-dumps:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
ref: main
25+
fetch-depth: 0
26+
submodules: recursive
27+
28+
- name: Set up repository and install Rust
29+
run: |
30+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
31+
source $HOME/.cargo/env
32+
33+
- name: Create new branch and run dump
34+
run: |
35+
# Configure git
36+
git config --local user.email "[email protected]"
37+
git config --local user.name "Bastian Gruber"
38+
39+
# Create new branch
40+
BRANCH_NAME="update-remote-settings-dumps-$(date +%Y%m%d)"
41+
git checkout -b $BRANCH_NAME
42+
43+
# Run the dump command
44+
cargo remote-settings dump-sync
45+
46+
# Check for changes and create PR if needed
47+
git add ./components/remote_settings/dumps/
48+
if git status --porcelain -- ./components/remote_settings/dumps/ | grep .; then
49+
git commit -m "chore: Update remote settings dumps"
50+
git push origin $BRANCH_NAME
51+
52+
# Create the PR (gh is installed on GH Actions)
53+
gh pr create \
54+
--title "Update Remote Settings Dumps" \
55+
--body "Automated PR to update remote settings dumps.
56+
57+
Changes detected in: \`./components/remote_settings/dumps/\`
58+
Generated by the Update Remote Settings Dumps workflow." \
59+
--base main \
60+
--head $BRANCH_NAME
61+
else
62+
echo "No changes detected in dumps directory"
63+
fi

0 commit comments

Comments
 (0)