-
Notifications
You must be signed in to change notification settings - Fork 251
137 lines (118 loc) · 5.15 KB
/
bake-blueprints.yaml
File metadata and controls
137 lines (118 loc) · 5.15 KB
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
# Copyright (c) 2025 Willem 'Jip' Wijnia
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: Bake blueprints
on:
workflow_dispatch:
inputs:
blueprints:
required: true
type: choice
description: The type of blueprints to bake properties into
options:
- props
- units
- projectiles
- emitters
reference:
required: true
type: choice
description: The reference (branch or tag) to use as a basis for baking.
options:
- develop
- staging/faf
- staging/fafbeta
- staging/fafdevelop
env:
COMMIT_MESSAGE: "Bake properties of ${{ inputs.blueprints }}\r\n\r\nThis commit originates from automation through GitHub Actions. The run was initiated by ${{ github.actor }}.\r\n\r\nThe run can be found at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."
PULL_REQUEST_BODY: "This pull request originates from automation through GitHub Actions. The run was initiated by ${{ github.actor }}.\r\n\r\nThe run can be found at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. It involves the baking of properties into blueprints of ${{ inputs.blueprints }}. By baking in the properties we make it easier to understand the behavior of the blueprints."
jobs:
bake-blueprints:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
# Checkout the wiki generator that we use to bake blueprints
- name: Checkout Brewlan Wikigen Repository
uses: actions/checkout@v4
with:
repository: The-Balthazar/BrewWikiGen
path: ./brew-wiki-gen
# Checkout the FA repository
- name: Checkout FAF Repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.reference }}
ssh-key: ${{ secrets.SSH_FAFOREVER_MACHINE_USER }}
path: ./fa
sparse-checkout-cone-mode: false
sparse-checkout: |
*.lua
*.bp
# Install the correct version of Lua for the wiki generator
- name: Install Lua 5.4
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "5.4"
# Prepare the run file
- name: Replace run.lua
run: |
FILE="fa/.github/workflows/scripts/baking/bake-${{ inputs.blueprints }}.lua"
if [ ! -f "$FILE" ]; then
echo "Error: File $FILE does not exist."
exit 1
fi
sudo cp "$FILE" brew-wiki-gen/Run.lua
# Use the wiki generator to bake the properties
- name: Execute lua run
run: |
lua brew-wiki-gen/Run.lua --OutputDirectory="fa.wiki/" --WikiGeneratorDirectory="brew-wiki-gen/" --FADirectory="fa/"
# Create a branch, commit and pull request
- name: Create a pull request
if: github.event_name == 'workflow_dispatch'
working-directory: fa
run: |
git config user.email "github@faforever.com"
git config user.name "FAForever Machine User"
git checkout -b bake/${{ inputs.blueprints }}-${{ github.run_id }}
git stage .
git commit -m "${{ env.COMMIT_MESSAGE }}"
git push origin bake/${{ inputs.blueprints }}-${{ github.run_id }}
# Install GitHub CLI (gh)
sudo apt update
sudo apt install gh -y
# Authenticate gh (use GITHUB_TOKEN)
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
# Create a pull request
gh pr create \
--title "Bake properties of ${{ inputs.blueprints }}" \
--body "${{ env.PULL_REQUEST_BODY }}" \
--base "${{ github.ref_name }}" \
--head "bake/${{ inputs.blueprints }}-${{ github.run_id }}"
# Create a commit and push it
- name: Create a commit
if: github.event_name != 'workflow_dispatch'
working-directory: fa
run: |
git config user.email "github@faforever.com"
git config user.name "FAForever Machine User"
git add .
git commit -m "${{ env.COMMIT_MESSAGE }}"
git push