Skip to content

Commit

Permalink
ci: refactor and run build also on main branch (#177)
Browse files Browse the repository at this point in the history
* ci: refactor

* ci: add step to determine that none of the dependant job failed

* ci: change if condition syntax

* ci: remove unexisting job reference

* ci: fix typo

* ci: try to remove name of action

* ci: add outputs for next version precomputation

* ci: alway run success job

* ci: cleanup
  • Loading branch information
kelvin-olaiya authored Jul 15, 2024
1 parent 13cc71b commit 5165d62
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 114 deletions.
126 changes: 123 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ name: Revue CI

on:
push:
branches: [ '**', '!main' ]
workflow_dispatch:
defaults:
run:
shell: bash

jobs:
build:
strategy:
Expand All @@ -31,7 +29,6 @@ jobs:
run: ./gradlew build --info
- name: Test
run: ./gradlew auth:test user:test alarm:test device:test log:test notification:test location:test --info

style:
runs-on: ubuntu-latest
steps:
Expand All @@ -45,3 +42,126 @@ jobs:
run: ./gradlew format --info
- name: Check lint
run: ./gradlew lint --info
compute-next-version:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
outputs:
will-release: ${{ steps.compute-next-version.outputs.will-release }}
next-version: ${{ steps.compute-next-version.outputs.next-version }}
steps:
- name: Checkout repo
uses: actions/[email protected]
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '21'
cache: 'npm'
- name: Pre-compute the next version
id: compute-next-version
uses: nicolasfara/[email protected]
with:
github-token: ${{ secrets.GH_TOKEN }}
- name: Use the next version
run: |
echo "Will release: ${{ steps.compute-next-version.outputs.will-release }}"
echo "The next version is ${{ steps.compute-next-version.outputs.next-version }}"
release:
needs:
- build
- style
runs-on: ubuntu-latest
concurrency:
# Only one release job at a time per branch, strictly sequential.
group: release-${{ github.event.number || github.ref }}
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release
docker:
name: Push ${{ matrix.image }} image to docker hub
strategy:
matrix:
image:
- alarm
- auth
- device
- frontend
- location
- log
- monitoring
- notification
- recognition
- user
needs:
- compute-next-version
- release
runs-on: ubuntu-latest
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
) && fromJSON(needs.compute-next-version.outputs.will-release)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/[email protected]
with:
context: ./${{ matrix.image }}
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: true
tags: |
letsdothisshared/revue-${{ matrix.image }}:${{ needs.compute-next-version.outputs.next-version }}
letsdothisshared/revue-${{ matrix.image }}:latest
success:
runs-on: ubuntu-latest
needs:
- build
- style
- release
- docker
- compute-next-version
# Always run this job, even if the previous jobs failed
if: >-
always() && (failure() || !contains(join(needs.*.result, ','), 'cancelled'))
steps:
- name: None of the dependant jobs should fail
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}
111 changes: 0 additions & 111 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit 5165d62

Please sign in to comment.