Files
bab-app/.gitea/workflows/build.yaml
Patrick Toal f2c4e73b8c
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m31s
fix(build): fix ansible trigger
2026-03-20 13:45:28 -04:00

71 lines
2.0 KiB
YAML

name: Build BAB Application Deployment Artifact
run-name: ${{ gitea.actor }} is building a BAB App artifact 🚀
on:
push:
branches:
- main
- alpha
- devel
jobs:
build:
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Enable Corepack and Yarn
run: |
corepack enable
corepack prepare yarn@stable --activate
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Create env file
run: echo "${{ vars.ENV_FILE }}" > .env
- name: Show env file
run: cat .env
- name: Build and Release
id: build
run: yarn semantic-release
env:
GITEA_TOKEN: ${{ secrets.GT_TOKEN }}
GITEA_URL: ${{ vars.GT_URL }}
- name: Trigger Ansible Deploy Playbook
if: steps.build.outputs.VERSION != ''
run: |
response=$(curl -sS \
-H "Authorization: Bearer ${{ secrets.WEBHOOK_SECRET }}" \
-H "Content-Type: application/json" \
-d '{"artifact_url":"${{ gitea.server_url }}/${{ gitea.repository }}/releases/download/v${{ steps.build.outputs.VERSION }}/release-${{ steps.build.outputs.VERSION }}.tar.gz"}' \
-w "\n%{http_code}" \
"${{ vars.WEBHOOK_URL }}")
http_code=$(echo "$response" | tail -1)
body=$(echo "$response" | head -n -1)
echo "Response: $body"
echo "HTTP status: $http_code"
[ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]