-
Notifications
You must be signed in to change notification settings - Fork 3
72 lines (64 loc) · 2.41 KB
/
setup.yml
File metadata and controls
72 lines (64 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Setup
on: push
jobs:
setup:
if: (github.event.commits[0].message == 'Initial commit') && (github.run_number == 1)
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Copy Repository Contents
uses: actions/checkout@v2
- name: modify files
run: |
import re, os
from pathlib import Path
from configparser import ConfigParser
nwo = os.getenv('GITHUB_REPOSITORY')
username, repo_name = nwo.split('/')
script_path = Path('scripts/experiments.sh')
script = script_path.read_text().replace('codingpot', username)
script = script.replace('git-mlops', repo_name)
script_path.write_text(script)
script_path = Path('scripts/jl_exp_wandb.sh')
script = script_path.read_text().replace('codingpot', username)
script = script.replace('git-mlops', repo_name)
script_path.write_text(script)
shell: python
- name: get unsername and reponame
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: |
export username="$(cut -d'/' -f1 <<<$GITHUB_REPOSITORY)"
export repo_name="$(cut -d'/' -f2 <<<$GITHUB_REPOSITORY)"
echo "::set-env name=username::$username"
echo "::set-env name=repo_name::$repo_name"
- name: commit changes
run: |
git config --global user.email "${GH_EMAIL}"
git config --global user.name "${GH_USERNAME}"
git checkout -B automated-setup
git rm .github/workflows/setup.yml
git add .
git commit -m 'setup repo'
git push -f --set-upstream origin automated-setup
env:
GH_EMAIL: ${{ github.event.commits[0].author.email }}
GH_USERNAME: ${{ github.event.commits[0].author.username }}
- name: Open a PR
uses: actions/github-script@0.5.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
var contents = 'your initial PR';
github.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Initial Setup',
head: 'automated-setup',
base: 'main',
body: `${contents}`
});