Skip to content

Commit

Permalink
Create a deploy workflow pt. 2 (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas authored May 28, 2024
1 parent 4cab4ca commit 67a5af0
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 137 deletions.
36 changes: 28 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Copyright (c) 2024 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: build

on:
Expand All @@ -19,20 +39,20 @@ jobs:
cache: npm
node-version: 20.x

- name: Installation
- name: Install
run: |
npm install
npm install bower
npm install grunt-cli
npx bower install
- name: Building
- name: Build
run: |
grunt build
# - name: Uploading
# uses: actions/upload-artifact@v4
# with:
# name: spookydb-dist
# path: |
# dist
- name: Upload
uses: actions/upload-artifact@v4
with:
name: spookydb-dist
path: |
dist
57 changes: 38 additions & 19 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
# Copyright (c) 2024 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: deploy

on:
workflow_dispatch:

jobs:
update:
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
name: update blueprint information
uses: FAForever/spooky-db/.github/workflows/generate.yaml@main
uses: FAForever/spooky-db/.github/workflows/update.yaml@master

deploy:
needs: [update]
name: deploy application
name: deploy
runs-on: ubuntu-latest
steps:
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

# https://github.com/actions/checkout/tree/v4/
- name: Checkout spooky db code
uses: actions/checkout@v4
Expand All @@ -33,23 +52,23 @@ jobs:
path: gh-pages
ref: gh-pages

# - name: Installation
# working-directory: spookydb
# run: |
# npm install
# npm install bower
# npm install grunt-cli
# npx bower install

# - name: Building
# working-directory: spookydb
# run: |
# grunt build
- name: Installation
working-directory: spookydb
run: |
npm install
npm install bower
npm install grunt-cli
npx bower install
- name: Deploying
working-directory: gh-pages
- name: Building
working-directory: spookydb
run: |
git log
grunt build
# - name: Deploying
# working-directory: gh-pages
# run: |
# git log

- name: Uploading
uses: actions/upload-artifact@v4
Expand Down
110 changes: 0 additions & 110 deletions .github/workflows/generate.yaml

This file was deleted.

136 changes: 136 additions & 0 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@

# Copyright (c) 2024 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: update

on:
workflow_call:
workflow_dispatch:

jobs:
update:
name: generate
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout spooky db code
uses: actions/checkout@v4

- name: Checkout FAForever blueprints and lua files
uses: actions/checkout@v4
with:
repository: FAForever/fa
path: fa
sparse-checkout-cone-mode: false
sparse-checkout: |
*.bp
*.lua
- name: Checkout Nomads blueprints and lua files
uses: actions/checkout@v4
with:
repository: FAForever/nomads
path: nomads
sparse-checkout-cone-mode: false
sparse-checkout: |
*.bp
# Prepare the Lua context

- name: Install Lua
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "5.1.5"

- uses: leafo/gh-actions-luarocks@v4

- name: Install JSON module for Lua
run: luarocks install dkjson

# Prepare the script context

- name: Prepare for the script
shell: bash
run: |
mkdir tools/temp
mkdir tools/temp/units
mkdir tools/temp/lua
mv -f fa/units/* tools/temp/units
mv -f nomads/units/* tools/temp/units
mv fa/lua/version.lua tools/temp/lua/version.lua
- name: Run the script
shell: pwsh
working-directory: tools # script expects this directory
run: |
lua -v
pwsh ./index.ps1 -target ../app -inputUnits "temp/units" -inputLua "temp/lua"
# Store the created files

- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: Generated files
path: |
app/data
# Update the repository

- name: Retrieve commit hash of FA repository
id: hashFA
working-directory: fa
run: |
hash=`git rev-parse --verify HEAD`
echo "hash=$hash" >> $GITHUB_OUTPUT
- name: Retrieve commit hash of Nomads repository
id: hashNomads
working-directory: nomads
run: |
hash=`git rev-parse --verify HEAD`
echo "hash=$hash" >> $GITHUB_OUTPUT
- name: Update repository
working-directory: app/data
run: |
# Check for any differences between the working directory and the latest commit
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi
# Configure git
git config user.email "[email protected]"
git config user.name "FAForever"
# Stage, commit and push the changes
git stage .
git commit -m 'Update unit blueprint information
Commit hash of FA repository: ${{ steps.hashFA.outputs.hash }}
Commit hash of Nomads repository: ${{ steps.hashNomads.outputs.hash }}'
git push origin HEAD:master
# git tag "${{ fromJson(steps.gameVersionJSON.outputs.json).version}}"
# git tag push

0 comments on commit 67a5af0

Please sign in to comment.