-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (61 loc) · 2.55 KB
/
ci.yml
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
name: Changed Data Files
on:
push:
branches:
- dev/test/api
paths:
- '.github/workflows/**'
- 'src/_data/**.js'
- 'src/_data/**.yml'
- 'src/pages/api/**.njk'
- 'src/_includes/modules/api-config.njk'
- 'src/_includes/modules/components/**'
env:
TEMP_BRANCH: "${{ vars.TEMP_BRANCH }}"
BASE_BRANCH: "${{ vars.BASE_BRANCH }}"
DEST_BRANCH: "${{ vars.DEST_BRANCH }}"
CI_COMMIT_AUTHOR: ${{ vars.CI_COMMIT_AUTHOR }}
CI_COMMIT_EMAIL: ${{ vars.CI_COMMIT_EMAIL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
env_var: ${{ vars.ENV_CONTEXT_VAR }}
jobs:
automatic-pr:
runs-on: ubuntu-latest
environment: ${{ vars.ENVIRONMENT_STAGE }}
name: Automatic PR
steps:
- name: checkout specific files
id: checkout-files
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ env.DEST_BRANCH }}
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYYMMDD-HHMMSS
timezone: America/New_York
- name: set commit/pr message
id: message
run: |
title="✅ CI: automatically update ${{ env.DEST_BRANCH }} from ${{ env.BASE_BRANCH }} 🙌📟🎉"
body="🚀 Automated PR created via Github action by ${{ env.CI_COMMIT_AUTHOR }} :octocat: on ${{ steps.current-time.outputs.readableTime }} 📅⏳\nRepository: ${{ github.repository }}\nActor: ${{ github.actor }}\nRef: ${{ github.ref }}
"
echo "title=$title" >> $GITHUB_OUTPUT
echo "body=$body" >> $GITHUB_OUTPUT
- name: create branch from destination branch and checkout files from base branch
id: new-branch
run: |
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git fetch origin
git push -d origin $TEMP_BRANCH &>/dev/null || true
git branch -d $TEMP_BRANCH &>/dev/null || true
git checkout -b $TEMP_BRANCH
git checkout $BASE_BRANCH -- .github/workflows src/_data src/pages/api src/_includes/modules/api-config.njk src/_includes/modules/components
git add -A
git commit -m "${{ steps.message.outputs.title }}"
git push --set-upstream origin $TEMP_BRANCH
- name: create pull request
run: gh pr create -B $DEST_BRANCH -H $TEMP_BRANCH --title "${{ steps.message.outputs.title }}" --body "${{ steps.message.outputs.body }}" --draft --label "automation" --reviewer "rediris"