Skip to content

Commit

Permalink
ci: trigger nightly build on push to develop (#434)
Browse files Browse the repository at this point in the history
"nightly" is renamed to "develop" everywhere (workflow name, docker image...)
  • Loading branch information
TdyP authored Mar 28, 2024
1 parent f8a1654 commit 69e550c
Showing 1 changed file with 24 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
name: Nightly build
name: Build develop

on:
push:
branches:
- develop
workflow_dispatch:
schedule:
# Every day at midnight
- cron: '0 0 * * *'

jobs:
# Check if a build is needed: if the last successful nightly build has been made on the same commit
# as the current one, then a build is not needed
check:
runs-on: 'ubuntu-latest'
steps:
-
uses: octokit/[email protected]
id: check_last_run
with:
route: GET /repos/${{github.repository}}/actions/workflows/nightly.yml/runs?per_page=1&status=completed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: "echo Last nightly build sha: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }}"
- run: "echo Current build sha: ${{ github.sha }}"
- run: "echo Should run: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha != github.sha }}"

outputs:
should_run: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha != github.sha }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Build core and deploy it to Docker Hub
core:
needs: [check]
if: needs.check.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version # Write version to package.json and manifest.json
run: |
echo "Setting version to \"nightly (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"nightly (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
echo "Setting version to \"develop (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"develop (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -56,19 +39,17 @@ jobs:
labels:
LEAV Engine
Core
tags: "leavengine/core:nightly"
tags: "leavengine/core:develop"

# Build preview-generator and deploy it to Docker Hub
preview-generator:
needs: [check]
if: needs.check.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version # Write version to package.json and manifest.json
run: |
echo "Setting version to \"nightly (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"nightly (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
echo "Setting version to \"develop (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"develop (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -91,19 +72,17 @@ jobs:
labels:
LEAV Engine
Preview Generator
tags: "leavengine/preview-generator:nightly"
tags: "leavengine/preview-generator:develop"

# Build automate-scan and deploy it to Docker Hub
automate-scan:
needs: [check]
if: needs.check.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version # Write version to package.json and manifest.json
run: |
echo "Setting version to \"nightly (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"nightly (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
echo "Setting version to \"develop (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"develop (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -126,19 +105,17 @@ jobs:
labels:
LEAV Engine
Automate Scan
tags: "leavengine/automate-scan:nightly"
tags: "leavengine/automate-scan:develop"

# Build sync-scan and deploy it to Docker Hub
sync-scan:
needs: [check]
if: needs.check.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version # Write version to package.json and manifest.json
run: |
echo "Setting version to \"nightly (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"nightly (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
echo "Setting version to \"develop (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"develop (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -161,19 +138,17 @@ jobs:
labels:
LEAV Engine
Sync scan
tags: "leavengine/sync-scan:nightly"
tags: "leavengine/sync-scan:develop"

# Build logs-collector and deploy it to Docker Hub
logs-collector:
needs: [check]
if: needs.check.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version # Write version to package.json and manifest.json
run: |
echo "Setting version to \"nightly (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"nightly (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
echo "Setting version to \"develop (${{ github.sha }})\""
find \( -name "package.json" -o -name "manifest.json" \) -not -path "*/node_modules/*" -not -path "*/__tests__/*" -type f -exec sh -c 'jq ".version = \"develop (${{ github.sha }})\"" {} > tmpfile && mv tmpfile {}' \;
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -196,4 +171,4 @@ jobs:
labels:
LEAV Engine
Logs Collector
tags: "leavengine/logs-collector:nightly"
tags: "leavengine/logs-collector:develop"

0 comments on commit 69e550c

Please sign in to comment.