-
Notifications
You must be signed in to change notification settings - Fork 10
167 lines (146 loc) · 6.79 KB
/
GuideConverterV3Action.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: GuideConverterV3
on:
workflow_dispatch:
inputs:
branch:
description: 'Guide branch pushed to'
required: true
default: 'prod'
guide_name:
description: 'Guide changed'
required: true
default: 'guide-rest-intro'
converter_branch:
description: 'Converter branch'
required: true
default: 'main'
common_branch:
description: 'guides-common branch for staging only'
required: true
default: 'prod'
jobs:
printBranch:
runs-on: ubuntu-latest
steps:
- name: Output message
run: |
echo "branch: ${{ github.event.inputs.branch }}"
echo "guide_name: ${{ github.event.inputs.guide_name }}"
echo "converter_branch: ${{ github.event.inputs.converter_branch }}"
echo "common_branch: ${{ github.event.inputs.common_branch }}"
convertMaster:
name: Make PR to Master
runs-on: ubuntu-latest
if: contains(github.event.inputs.branch, 'master') || contains(github.event.inputs.branch, 'main') || contains(github.event.inputs.branch, 'prod')
steps:
# Any prerequisite steps
- uses: actions/checkout@master
- name: Checkout Guide Converter repo
uses: actions/checkout@v2
with:
repository: OpenLiberty/cloud-hosted-guide-converter
path: GuideConverter
- name: Checkout guide repo
uses: actions/checkout@v2
with:
repository: OpenLiberty/${{ github.event.inputs.guide_name }}
path: GuideConverter/${{ github.event.inputs.guide_name }}
- name: Checkout guides-common repo
uses: actions/checkout@v2
with:
repository: OpenLiberty/guides-common
path: GuideConverter/guides-common
- uses: actions/setup-java@v1
with:
java-version: '16' # The JDK version to make available on the path.
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64
- name: Run Converter
run: |
branchName=${{ github.event.inputs.branch }}
git init
mkdir -p instructions/cloud-hosted-${{ github.event.inputs.guide_name }}/labs
cd GuideConverter
mvn -ntp compiler:compile
mvn -ntp exec:java -Dexec.args="${{ github.event.inputs.guide_name }} ${branchName:11} cloud-hosted-${{ github.event.inputs.guide_name }}"
rm -f importFunctions.class
rm -f functions.class
rm -f CloudHostedGuideConverter.class
cd ..
mv GuideConverter/${{ github.event.inputs.guide_name }}.md instructions/cloud-hosted-${{ github.event.inputs.guide_name }}/labs/cloud-hosted-${{ github.event.inputs.guide_name }}.md
rm -rf GuideConverter
bash .github/workflows/draftRemoval.sh cloud-hosted-${{ github.event.inputs.guide_name }}
git add .
git config --global user.email "[email protected]"
git config --global user.name "GuidesBot"
git commit -m "Updated by github actions from ${{ github.event.inputs.guide_name }}"
git checkout --ours instructions/cloud-hosted-${{ github.event.inputs.guide_name }}/labs/cloud-hosted-${{ github.event.inputs.guide_name }}.md
- uses: peter-evans/create-pull-request@v3
with:
title: "To Prod: Change to cloud-hosted-${{ github.event.inputs.guide_name }}"
token: ${{ secrets.GUIDECONVERSIONTOOL_PASSWORD }}
body: "Updated by github actions, triggered by the ${{ github.event.inputs.guide_name }} repo."
branch: "cloud-hosted-${{ github.event.inputs.guide_name }}/prod"
base: "prod"
labels: "RunTests"
name: Create Pull Request
convertStaging:
name: Make PR to Staging
runs-on: ubuntu-latest
if: contains(github.event.inputs.branch, 'qa') || contains(github.event.inputs.branch, 'staging')
steps:
- uses: actions/checkout@v2
with:
ref: staging
- name: Checkout Guide Converter repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.converter_branch }}
repository: OpenLiberty/cloud-hosted-guide-converter
path: GuideConverter
- name: Checkout guide repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
repository: OpenLiberty/${{ github.event.inputs.guide_name }}
path: GuideConverter/${{ github.event.inputs.guide_name }}
- name: Checkout guides-common repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.common_branch }}
repository: OpenLiberty/guides-common
path: GuideConverter/guides-common
- uses: actions/setup-java@v1
with:
java-version: '16' # The JDK version to make available on the path.
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64
- name: Run Converter
run: |
branchName=${{ github.event.inputs.branch }}
git init
mkdir -p instructions/cloud-hosted-${{ github.event.inputs.guide_name }}/labs
cd GuideConverter
mvn -ntp compiler:compile
mvn -ntp exec:java -Dexec.args="${{ github.event.inputs.guide_name }} ${branchName} cloud-hosted-${{ github.event.inputs.guide_name }}"
rm -f importFunctions.class
rm -f functions.class
rm -f CloudHostedGuideConverter.class
cd ..
mv GuideConverter/${{ github.event.inputs.guide_name }}.md instructions/cloud-hosted-${{ github.event.inputs.guide_name }}/labs/cloud-hosted-${{ github.event.inputs.guide_name }}.md
rm -rf GuideConverter
bash .github/workflows/draftRemoval.sh cloud-hosted-${{ github.event.inputs.guide_name }}
git add .
git config --global user.email "[email protected]"
git config --global user.name "GuidesBot"
git commit -m "Updated by github actions from ${{ github.event.inputs.guide_name }}"
git checkout --ours instructions/cloud-hosted-${{ github.event.inputs.guide_name }}/labs/cloud-hosted-${{ github.event.inputs.guide_name }}.md
- uses: peter-evans/create-pull-request@v3
with:
title: "To Staging: Change to cloud-hosted-${{ github.event.inputs.guide_name }}"
token: ${{ secrets.GUIDECONVERSIONTOOL_PASSWORD }}
body: "Updated by github actions, triggered by the ${{ github.event.inputs.guide_name }} repo."
branch: "cloud-hosted-${{ github.event.inputs.guide_name }}/staging"
base: "staging"
labels: "RunTests"
name: Create Pull Request