-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (92 loc) · 3.52 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
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
95
name: Changed Data Files - Develop
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'
jobs:
automatic-pr:
runs-on: ubuntu-latest # windows-latest || macos-latest
name: Automatic PR
env:
TEMP_BRANCH: auto/dev/test/api
BASE_BRANCH: dev/test/api
DEST_BRANCH: dev/api
steps:
- name: checkout specific files
id: checkout-files
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ env.DEST_BRANCH }}
# sparse-checkout: |
# .github/workflows/
# src/_data/
# src/pages/api/
# src/_includes/modules/api-config.njk
# sparse-checkout-cone-mode: false
- name: create new branch
id: new-branch
run: |
git checkout -b $TEMP_BRANCH
git checkout $BASE_BRANCH -- .github/workflows src/_data src/pages/api src/_includes/modules/api-config.njk
git commit -m "auto: add updated files from $BASE_BRANCH"
git push --set-upstream origin $TEMP_BRANCH
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: set datestamp
id: datestamp
run: |
echo "datestamp=$(git log -1 --format=%cd --date=format:%Y-%m-%d-%H%M%S)" >> $GITHUB_OUTPUT
- name: create pull request
run: gh pr create -B $DEST_BRANCH -H $TEMP_BRANCH --title "[Auto PR] - ${{ steps.datestamp.outputs.datestamp }} Merge $TEMP_BRANCH into api/dev" --body "Automated PR Created by Github action" --draft --label "automation" --reviewer "rediris" --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# create_pr:
# runs-on: ubuntu-latest
# name: Create PR
# steps:
# - name: sparse checkout api/dev branch
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# ref: api/dev
# sparse-checkout: |
# .github/workflows/**
# src/_data/**.js
# src/_data/**.yml
# src/pages/api/**.njk
# /src/_includes/modules/api-config.njk
# sparse-checkout-cone-mode: false
# - name: create temp branch
# uses: carlsberg/[email protected]
# id: temp-branch
# with:
# base: api/dev
# - name: checkout specific files in develop branch
# run: |
# git checkout ${{ steps.temp-branch.outputs.branch }}
# git checkout develop -- .github/workflows/** src/_data/**.js src/_data/**.yml src/pages/api/**.njk /src/_includes/modules/api-config.njk
# - name: set datestamp
# id: datestamp
# run: |
# echo "datestamp=$(git log -1 --format=%cd --date=format:%Y-%m-%dh%H%M%S)" >> $GITHUB_OUTPUT
# - name: set PR message
# id: message
# run: |
# title="[Auto PR]: ${{ steps.datestamp.outputs.datestamp }} Update API - Dev"
# body="This PR was auto-generated on ${{ steps.datestamp.outputs.datestamp }} \
# by [create-pull-request](https://github.com/peter-evans/create-pull-request)."
# echo "title=$title" >> $GITHUB_OUTPUT
# echo "body=$body" >> $GITHUB_OUTPUT
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v7
# with:
# branch: auto/api/dev
# title: ${{ steps.message.outputs.title }}
# body: ${{ steps.message.outputs.body }}