Skip to content

Commit 2fc9001

Browse files
authored
CI add auto clean-up workflow (#51)
1 parent 0017b61 commit 2fc9001

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Benchmark creation
2+
3+
# This step triggers after a user creates a new repository from the template
4+
# It replaces the placeholder with the correct names and
5+
# cleans up template scripts
6+
7+
# This will run every time we create push a commit to `main`
8+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
9+
on:
10+
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
14+
15+
permissions:
16+
# Need `contents: read` to checkout the repository
17+
# Need `contents: write` to update the step metadata
18+
contents: write
19+
20+
jobs:
21+
clean_template:
22+
name: Clean up template
23+
runs-on: ubuntu-latest
24+
# Only run this action when this repository isn't the template repo
25+
if: ${{ !github.event.repository.is_template}}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v5
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: '3.12'
35+
- name: Clean template scripts
36+
run: |
37+
python clean_template.py
38+
39+
# Make a branch, file, commit, and pull request for the learner
40+
- name: Commit clean up on the repository
41+
run: |
42+
echo "Configure git"
43+
git config user.name github-actions[bot]
44+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
45+
46+
echo "Commit all changes"
47+
git commit -am="CLN remove template scripts"
48+
49+
echo "Push to main"
50+
git push
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This repo should be used with the following steps:
1414

1515
My Benchopt Benchmark
1616
=====================
17-
|Build Status| |Python 3.6+|
17+
|Build Status| |Python 3.10+|
1818

1919
Benchopt is a package to simplify and make more transparent and
2020
reproducible comparisons of optimization methods.
@@ -47,7 +47,7 @@ Use ``benchopt run -h`` for more details about these options, or visit https://b
4747

4848
.. |Build Template| image:: https://github.com/benchopt/template_benchmark/actions/workflows/main.yml/badge.svg
4949
:target: https://github.com/benchopt/template_benchmark/actions
50-
.. |Build Status| image:: https://github.com/#ORG/#BENCHMARK_NAME/actoiworkflows/main.yml/badge.svg
50+
.. |Build Status| image:: https://github.com/#ORG/#BENCHMARK_NAME/actions/workflows/main.yml/badge.svg
5151
:target: https://github.com/#ORG/#BENCHMARK_NAME/actions
52-
.. |Python 3.6+| image:: https://img.shields.io/badge/python-3.6%2B-blue
53-
:target: https://www.python.org/downloads/release/python-360/
52+
.. |Python 3.10+| image:: https://img.shields.io/badge/python-3.10%2B-blue
53+
:target: https://www.python.org/downloads/release/python-3100/

clean_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
to_remove = [
3333
Path(".github") / "workflows" / "test_benchmarks.yml",
3434
Path(".github") / "workflows" / "lint_benchmarks.yml",
35+
Path(".github") / "workflows" / "clean_template.yml",
3536
Path(".") / "clean_template.py"
3637
]
3738
for file in to_remove:

0 commit comments

Comments
 (0)