Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow specifying rebuild branch #176

Merged
merged 2 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 31 additions & 20 deletions .github/workflows/rebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,45 @@ on:
- created
push:
status:
env:
GITLAB_TRIGGER: https://gitlab.com/api/v4/projects/19345468/trigger/pipeline
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
jobs:
RandomRebuild:
if: github.event_name == 'schedule'
TriggerRebuild:
if: github.event_name == 'schedule' || github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!rebuild')
runs-on: ubuntu-latest
steps:
- run: |
cmd="$(jq -r .comment.body < "$GITHUB_EVENT_PATH" | head -n1 | cut -d' ' -f2-)"
while [[ "$cmd" != '' && "$cmd" != '!rebuild' ]]; do
arg="$(echo $cmd | cut -d' ' -f1)"
key="$(echo $arg | cut -d= -f1)"
val="$(echo $arg | cut -d= -f2)"
case "$key" in
branch)
branch="$val"
;;
file)
folder="$(echo $val | cut -d/ -f1)"
file="$(echo $val | cut -d/ -f2)"
;;
*)
echo "Unknown command $key"
exit 1
;;
esac
if echo "$cmd" | grep -q ' '; then
cmd="$(echo $cmd | cut -d' ' -f2)"
else
cmd=""
fi
done
curl --fail \
-F "token=$GITLAB_TOKEN" \
-F "ref=master" \
"$GITLAB_TRIGGER"
ManualRebuild:
if: github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!rebuild')
runs-on: ubuntu-latest
steps:
- run: |
arg="$(echo '${{ github.event.comment.body }}' | head -n1 | cut -d' ' -f2)"
folder="$(echo $arg | cut -d/ -f1)"
file="$(echo $arg | cut -d/ -f2)"
curl --fail \
-F "token=$GITLAB_TOKEN" \
-F "token=${{ secrets.GITLAB_TOKEN }}" \
-F "ref=master" \
-F "variables[BRANCH]=$branch" \
-F "variables[FOLDER]=$folder" \
-F "variables[FILE]=$file" \
"$GITLAB_TRIGGER"
- uses: actions/github-script@v2
https://gitlab.com/api/v4/projects/19345468/trigger/pipeline
- if: github.event_name == 'issue_comment'
uses: actions/github-script@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down
16 changes: 11 additions & 5 deletions make_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys

from random import choice
from sys import stdout
from uuid import uuid4

import yaml
Expand All @@ -21,6 +21,13 @@

tags = ["nvidia"] if file in GPU else []

branch = os.getenv("BRANCH")
if not branch:
branch = f"rebuild/{str(uuid4())[:8]}"
if not branch.startswith("rebuild/"):
print("Branch name must begin with 'rebuild/'")
sys.exit(1)

script = f"""
julia -e '
using Pkg
Expand All @@ -39,11 +46,10 @@
git config core.sshCommand "ssh -o StrictHostKeyChecking=no -i $SSH_KEY"
git config user.name "github-actions[bot]"
git config user.email "actions@github.com"
branch="rebuild/{str(uuid4())[:8]}"
git checkout -b "$branch"
git checkout -b {branch}
git commit -am "Rebuild tutorials"
git remote add github "git@github.com:SciML/DiffEqTutorials.jl.git"
git push github "$branch"
git push github {branch} -f
"""

pipeline = {
Expand All @@ -59,4 +65,4 @@
},
}

yaml.dump(pipeline, stdout)
yaml.dump(pipeline, sys.stdout)