-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
94 lines (85 loc) · 2.73 KB
/
action.yaml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: "cleanlab/deploy-bot"
description: "Deployment merge handler."
author: "Ryan Singman @ Cleanlab"
inputs:
source:
description: source branch to create merge from
required: false
default: "staging"
target:
description: target branch to merge into
required: false
default: "main"
pr_body:
description: contents of body of PR
required: false
default: ":robot: *Automated PR for daily deployment* :robot:"
pr_label:
description: labels for PR, as comma-separated list
required: false
default: ""
should_add_reviewers:
description: whether to add reviewers to PR
required: false
default: "true"
required_reviewers:
description: reviewers required for all PRs
required: false
default: ""
runs:
using: composite
steps:
# checkout <source> branch of repo
- uses: actions/checkout@v3
with:
ref: ${{ inputs.source }}
- uses: actions/setup-python@v4
with:
cache: "pip" # caching pip dependencies
- name: Create virtualenv
run: |
python -m venv ~/.venv
. ~/.venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
shell: bash
# install Python dependencies for action
- run: |
pip install -r $GITHUB_ACTION_PATH/requirements.txt
shell: bash
# set date str
- run: |
echo "DATE=$(date +'%m-%d-%Y')" >> $GITHUB_ENV
shell: bash
# name deployment branch
- run: |
echo "DEPLOYMENT_BRANCH=deployment/${{ env.DATE }}" >> $GITHUB_ENV
shell: bash
# create deployment branch off of source branch
# named deployment_{date}
- run: |
git checkout -b ${{ env.DEPLOYMENT_BRANCH }} \
&& git push --set-upstream origin ${{ env.DEPLOYMENT_BRANCH }}
shell: bash
# get list of reviewers for PR
- run: |
echo "REVIEWERS=$( \
GITHUB_TOKEN=${{ github.token }} \
python $GITHUB_ACTION_PATH/deploy_bot/get_reviewers.py \
--repository ${{ github.repository }} \
--head-branch=${{ env.DEPLOYMENT_BRANCH }} \
--base-branch=${{ inputs.target }} \
--required-reviewers=${{ inputs.required_reviewers }} \
--should-add-reviewers=${{ inputs.should_add_reviewers }} \
)" >> $GITHUB_ENV
shell: bash
# create PR to target branch from deployment branch
- uses: repo-sync/pull-request@v2
with:
source_branch: ${{ env.DEPLOYMENT_BRANCH }}
destination_branch: ${{ inputs.target }}
pr_title: "Deployment: ${{ env.DATE }}"
pr_body: ${{ inputs.pr_body }}
pr_label: ${{ inputs.pr_label }}
pr_allow_empty: false
pr_reviewer: ${{ env.REVIEWERS }}
github_token: ${{ github.token }}