-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep-2.sh
More file actions
executable file
·47 lines (37 loc) · 909 Bytes
/
Copy pathstep-2.sh
File metadata and controls
executable file
·47 lines (37 loc) · 909 Bytes
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
#!/bin/bash
SCRIPTDIR=$(cd $(dirname $0); pwd)
set -eu
cd $SCRIPTDIR/../github-actions
stepNum=2
stepName=staging
branchName="step-$stepNum"
startCommit=$(git log --reverse -n $stepNum --pretty=format:%H)
echo "startCommit $startCommit"
git reset --hard HEAD
git checkout main
if git rev-parse --verify $branchName &>/dev/null; then
git branch -D $branchName;
fi
echo "git checkout -b $branchName $startCommit"
git checkout -b $branchName $startCommit
mkdir -p .github/workflows
cat <<EOT > .github/workflows/main.yml
name: main branch jobs
on:
push:
branches:
- main
jobs:
$stepName:
environment: $stepName
runs-on: ubuntu-latest
steps:
- run: echo "Lint"
- run: echo "Build"
- run: echo "Test"
- run: echo "Publish"
- run: echo "Deploy"
EOT
git add .
git commit -m "$branchName $stepName workflow"
git push -uf origin $branchName