Daily Multi-OS Job #1136
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Daily Multi-OS Job | |
on: | |
schedule: | |
- cron: '0 2,8,14,20 * * *' # Runs at 2 AM, 8 AM, 2 PM, and 8 PM UTC every day | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
local_runners: | |
if: github.repository == 'Protofy-xyz/Protofy' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, ubuntu-20.04, macos-13, macos-12] # missing: windows-latest | |
fail-fast: false # Allow other jobs to continue if one fails | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.4' | |
cache: 'yarn' | |
- name: Health check versions | |
run: | | |
node -v | |
yarn -v | |
- name: Install NodeJS dependencies | |
run: yarn | |
- name: Start project | |
run: | | |
echo 'Started project' | |
yarn dev > /dev/null & | |
- name: Healthcheck services start | |
run: node .github/scripts/healthcheck-start.js | |
- name: Run Global tests | |
run: yarn test:global | |
- name: Save result | |
if: always() | |
run: node .github/scripts/save_result.js ${{ matrix.os }} ${{ job.status }} ${{ runner.temp }} | |
- name: Upload result # upload saved result as artifact to be consumed at notify job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: result-${{ matrix.os }} | |
path: ${{ runner.temp }}/result.txt | |
docker_runners: | |
if: github.repository == 'Protofy-xyz/Protofy' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Healthcheck versions | |
run: | | |
docker -v | |
docker compose version | |
docker-compose -v | |
id | |
groups | |
- name: Prepare Docker Volumes | |
run: | | |
cd docker | |
./init | |
- name: Build Image | |
run: | | |
cd docker | |
./build | |
- name: Start Docker project in Development and background | |
run: | | |
cd docker | |
source ./helpers/get-envs | |
$DOCKER_COMPOSE_CMD -p protofy $SERVICES_COMPOSE_FILES up -d | |
- name: Services logs | |
if: false # skip by deault enable for debugging purposes | |
run: | | |
cd docker | |
./logs | |
- name: Healthcheck docker services start | |
run: node .github/scripts/healthcheck-start.js | |
- name: Run global tests | |
run: docker exec -i site sh -c "yarn test:global" | |
- name: Save result | |
if: always() | |
run: node .github/scripts/save_result.js Docker_DEV ${{ job.status }} ${{ runner.temp }} | |
- name: Upload result # upload saved result as artifact to be consumed at notify job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: result-Docker_DEV | |
path: ${{ runner.temp }}/result.txt | |
notify: | |
runs-on: ubuntu-latest | |
needs: [local_runners, docker_runners] | |
if: always() && github.repository == 'Protofy-xyz/Protofy' # This ensures that the notification job runs whether the build job succeeds or fails | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
- name: Combine results | |
run: | | |
for result_dir in result-*; do | |
if [ -d "$result_dir" ]; then | |
cat "$result_dir/result.txt" >> combined_results.txt | |
fi | |
done | |
echo "Combined results result:" | |
echo "RESULTS<<EOF" >> $GITHUB_ENV | |
cat combined_results.txt >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Daily build Report | |
uses: rjstone/discord-webhook-notify@v1 | |
env: | |
RESULTS: ${{ env.RESULTS }} | |
with: | |
severity: info | |
color: '#a600e0' | |
avatarUrl: https://raw.githubusercontent.com/Protofy-xyz/Protofy/assets/protofito_purple.png | |
description: | | |
Daily OS Build Report 👀 | |
${{ env.RESULTS }} | |
footer: Daily report. | |
text: 🚨 Check daily report! 🚨 | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} |