Skip to content

fix: don't add frontend dir into plugin dist as it is not needed (#11) #151

fix: don't add frontend dir into plugin dist as it is not needed (#11)

fix: don't add frontend dir into plugin dist as it is not needed (#11) #151

Workflow file for this run

name: CI
on:
pull_request:
types:
- closed
push:
branches:
- main
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
outputs:
submodule-matrix: ${{ steps.discover-submodules.outputs.submodule-matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
persist-credentials: true
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install pnpm
run: npm install -g pnpm
- name: Discover submodules
id: discover-submodules
run: |
sudo node ./scripts/generate-metadata.js
sudo node ./scripts/discover-submodules.js > submodules.json
cat submodules.json
echo "submodule-matrix=$(cat submodules.json)" >> $GITHUB_OUTPUT
- name: Commit Metadata
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Stage the changes
git add metadata.json
# Commit only if there are changes
if git commit -m "chore: Add plugin metadata"; then
# Push only if the commit succeeded
git push
else
echo "::debug::No changes to commit."
fi
make:
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repository: ${{ fromJson(needs.prepare.outputs.submodule-matrix) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: ${{ matrix.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
submodules: recursive
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install Database SDK
run: |
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get update && sudo apt-get install google-cloud-cli
- name: Authenticate to Database
env:
GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
run: |
echo "${GCP_SERVICE_ACCOUNT_KEY}" > gcloud-key.json
gcloud auth activate-service-account --key-file=gcloud-key.json
gcloud config set project steam-brew
- name: Install pnpm
run: npm install -g pnpm
- name: Install Dependencies
run: |
pnpm install
env:
NODE_ENV: production
- name: Build Plugin
run: |
pnpm run build
env:
NODE_ENV: production
- name: Prepare Distribution Files
id: prepare-distribution
run: |
mkdir -p dist
cp -r ".millennium" dist/.millennium 2>/dev/null || echo "::error::.millennium directory not found, it is required to run the plugin."
cp "plugin.json" dist/plugin.json 2>/dev/null || { echo "::error::plugin.json was not found. It is required for plugins to have."; exit 1; }
cp "requirements.txt" dist/requirements.txt 2>/dev/null || echo "::debug::requirements.txt not found, skipping."
cp "README.md" dist/README.md 2>/dev/null || echo "::debug::README.md not found, skipping."
cp "README" dist/README 2>/dev/null || echo "::debug::README not found, skipping."
BACKEND_DIR=$(jq -r '.backend' plugin.json)
if [ "$BACKEND_DIR" != "null" ]; then
cp -r "$BACKEND_DIR" ./dist/"$BACKEND_DIR"
else
cp -r "backend" ./dist/backend 2>/dev/null || echo "::debug::backend directory not found, skipping."
fi
include=$(jq -r '.include // [] | .[]' plugin.json)
if [ -z "$include" ]; then
echo "::debug::No additional files to include."
else
echo "::debug::Including additional files: $include"
for item in $include; do
mkdir -p "./dist/$(dirname "$item")"
cp -r "./$item" "./dist/$item"
done
fi
echo "::debug::Computing plugin metadata..."
echo "{\"commit\": \"$(git rev-parse HEAD)\", \"id\": \"$(git rev-list --max-parents=0 HEAD)\"}" > dist/metadata.json
id=$(jq -r '.id' dist/metadata.json)
# Get repository name from the matrix
REPOSITORY_NAME=$(echo ${{ matrix.repository }} | cut -d'/' -f2)
echo "id=$REPOSITORY_NAME" >> $GITHUB_OUTPUT
cd dist
echo "::debug::Building plugin archive..."
zip -r "$REPOSITORY_NAME.zip" .
echo "::debug::Successfully built plugin."
echo "::debug::Uploading plugin to database..."
gsutil cp "$REPOSITORY_NAME.zip" gs://millennium-d9ce0.appspot.com/plugins/"$id.zip"
echo "::debug::Successfully uploaded plugin to database."
- name: Upload Plugin Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare-distribution.outputs.id }}
path: dist/${{ steps.prepare-distribution.outputs.id }}.zip