forked from CDCgov/prime-reportstream
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 2.14 KB
/
prepare_deployment_branch.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
name: "Prepare Deployment Branch"
on:
schedule:
# At 23:00 on Monday and Wednesday (https://crontab.guru/#0_16_*_*_1,3)
# GitHub actions run in UTC (and EDT is UTC-4)
- cron: "0 23 * * 1,3"
jobs:
prepare_branch:
name: "Prepare the deployment branch and file a PR"
runs-on: ubuntu-latest
steps:
- name: "Check out changes"
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- name: Set Environment Variables
# 86400: seconds in a 24h time-window
run: |
let TOMORROWS_SECONDS_SINCE_EPOCH=$(date +%s)+86400
DEPLOYMENT_DATE=$(date --date=@${TOMORROWS_SECONDS_SINCE_EPOCH} +%Y-%m-%d)
echo >> ${GITHUB_ENV} DEPLOYMENT_DATE=${DEPLOYMENT_DATE?}
echo >> ${GITHUB_ENV} BRANCH_NAME=deployment/${DEPLOYMENT_DATE?}
- name: Output Branch Name
run: |
echo "Branch name: \"${BRANCH_NAME}\""
- name: "Create branch '${{ env.BRANCH_NAME }}' to contain the changes for the deployment on ${{ env.DEPLOYMENT_DATE }}"
uses: peterjgrainger/action-create-branch@c2800a3a9edbba2218da6861fa46496cf8f3195a
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: "${{ env.BRANCH_NAME }}"
- name: "Prepare a Pull Request from ${{ env.BRANCH_NAME }} into production branch"
uses: k3rnels-actions/pr-update@2c8df8a7aacba86aac079e5a6acd74305af07d9c
id: pr
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Deployment of ${{ env.DEPLOYMENT_DATE }}"
pr_source: "${{ env.BRANCH_NAME }}"
pr_target: "production"
pr_labels: devops,chore,deployment
pr_assignees: jimduff-usds,MauriceReeves-usds,CDCgov/prime-reportstream-devops
pr_body: |
## Deployment of ${{ env.DEPLOYMENT_DATE }}
This PR contains the changes that will go into the deployment scheduled for ${{ env.DEPLOYMENT_DATE }}.
- name: "Produce Pull Request URL"
run: |
echo "PR URL: https://github.com/CDCgov/prime-reportstream/pull/${{ steps.pr.outputs.pr_nr }}"
echo "PR Id: ${{ steps.pr.outputs.pr_nr }}"