Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CI workflow to improve code reuse #457

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/actions/scripts-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Setup maps-metadata scripts
inputs:
cache-name:
description: Name od cache
required: true
download-artifacts:
description: Whatever to try to fetch pre-build artifact for usage in CI workflow
required: false
default: 'true'
runs:
using: "composite"
steps:
- name: Download artifacts
if: ${{ inputs.download-artifacts == 'true' }}
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: .maps-cache
key: maps-cache-cache-v2-${{ inputs.cache-name }}-${{ github.sha }}
restore-keys: |
maps-cache-cache-v2-${{ inputs.cache-name }}-
- name: Install dependencies
shell: bash
run: ./scripts/install.sh
141 changes: 23 additions & 118 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
- uses: ./.github/actions/scripts-setup
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: .maps-cache
key: maps-cache-cache-v2-build-${{ github.sha }}
restore-keys: |
maps-cache-cache-v2-build-
- name: Install dependencies
run: ./scripts/install.sh
cache-name: build
download-artifacts: 'false'
- name: Build
run: source .envrc && make -j $(nproc)
- name: Test
Expand Down Expand Up @@ -89,31 +73,9 @@ jobs:
if: vars.ENABLE_BYAR_CHOBBY_PUSH && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Setup Python
uses: actions/setup-python@v5
- uses: ./.github/actions/scripts-setup
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: .maps-cache
key: maps-cache-cache-v2-chobby-${{ github.sha }}
restore-keys: |
maps-cache-cache-v2-chobby-
- name: Install dependencies
run: ./scripts/install.sh
cache-name: chobby
- name: Checkout BYAR-Chobby
uses: actions/checkout@v4
with:
Expand All @@ -127,23 +89,13 @@ jobs:
cp gen/mapDetails.lua BYAR-Chobby/LuaMenu/configs/gameConfig/byar/mapDetails.lua
cp gen/mapBoxes.conf BYAR-Chobby/LuaMenu/configs/gameConfig/byar/savedBoxes.dat
- name: Commit and push
run: |
cd BYAR-Chobby
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git remote -v
echo "[+] Git add"
git add .
echo "[+] Git status"
git status
if git diff-index --quiet HEAD; then
echo "No changes to commit"
exit 0
fi
echo "[+] Git commit"
git commit -m $'Automatic update of maps from maps-metadata\n\nFrom commit ${{ github.repository }}@${{ github.sha }}'
echo "[+] Git push"
git push
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: BYAR-Chobby
commit_message: |
Automatic update of maps from maps-metadata

From commit ${{ github.repository }}@${{ github.sha }}
deploy-spads-config:
runs-on: ubuntu-latest
needs: build-and-test
Expand All @@ -169,54 +121,22 @@ jobs:
cp gen/mapBattlePresets.conf spads_config_bar/etc/mapBattlePresets.conf
python3 scripts/py/update_spads_conf.py spads_config_bar/etc/spads_cluster.conf
- name: Commit and push
run: |
cd spads_config_bar
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git remote -v
echo "[+] Git add"
git add .
echo "[+] Git status"
git status
if git diff-index --quiet HEAD; then
echo "No changes to commit"
exit 0
fi
echo "[+] Git commit"
git commit -m $'Automatic update of maps from maps-metadata\n\nFrom commit ${{ github.repository }}@${{ github.sha }}'
echo "[+] Git push"
git push
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: spads_config_bar
commit_message: |
Automatic update of maps from maps-metadata

From commit ${{ github.repository }}@${{ github.sha }}
deploy-website:
runs-on: ubuntu-latest
needs: build-and-test
if: vars.WEBFLOW_COLLECTION_ID && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- uses: actions/cache@v4
if: ${{ !env.ACT }}
- uses: ./.github/actions/scripts-setup
with:
path: .maps-cache
key: maps-cache-cache-v2-website-${{ github.sha }}
restore-keys: |
maps-cache-cache-v2-website-
- name: Install dependencies
run: ./scripts/install.sh
cache-name: website
- name: Push to website
uses: nick-fields/retry@v3
with:
Expand All @@ -238,24 +158,9 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: gen-artifacts
path: gen
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
- uses: ./.github/actions/scripts-setup
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- name: Install dependencies
run: ./scripts/install.sh
cache-name: gdrive
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/sync_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,10 @@ jobs:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_SELF_DEPLOY_KEY }}
- name: Setup Python
uses: actions/setup-python@v5
- uses: ./.github/actions/scripts-setup
with:
python-version: 3.11
cache: pip
cache-dependency-path: scripts/py/requirements.txt
- uses: actions/setup-node@v4
with:
node-version: 22.11
cache: npm
cache-dependency-path: scripts/js/package-lock.json
- name: Install dependencies
run: ./scripts/install.sh
cache-name: sync_map
download-artifacts: 'false'
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
Expand Down