Skip to content

Commit

Permalink
Merge pull request #1054 from entur/split-ci-cd
Browse files Browse the repository at this point in the history
Split ci and cd into separate workflows
  • Loading branch information
testower authored Oct 24, 2024
2 parents 159d6a8 + ad559f2 commit 61a930b
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 58 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build
'on':
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.16
- name: Configure git user
run: |
git config --global user.name 'Latest version bot'
git config --global user.email 'latest-version-bot@entur.org'
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- run: npm ci --legacy-peer-deps
- run: npm run check
- run: npm run test -- --coverage
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@v2.3.0
env:
SONAR_TOKEN: ${{ secrets.ENTUR_SONAR_PASSWORD }}
SONAR_HOST_URL: https://sonarcloud.io
with:
args: >
-Dsonar.organization=enturas-github
-Dsonar.projectKey=entur_abzu
-Dsonar.sources=src
-Dsonar.tests=src
-Dsonar.test.inclusions=src/**/*.test.ts
-Dsonar.typescript.lcov.reportPaths=coverage/lcov.info
- name: Bump version
run: |
npm version minor
echo "VERSION=$(npm pkg get version | tr -d \")" >> $GITHUB_ENV
- run: npm run build
env:
REACT_APP_VERSION: ${{ env.VERSION }}
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: |
build
- name: Push version update to GitHub
run: git push && git push --tags
Original file line number Diff line number Diff line change
@@ -1,69 +1,24 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy

name: Build and deploy
'on':
push:
branches:
- master
jobs:
build:
permissions:
checks: write
steps:
- uses: actions/checkout@v4
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
on:
workflow_run:
workflows: [Build]
types:
- completed

- if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- run: npm ci --legacy-peer-deps
- run: npm run check
- run: npm run test -- --coverage
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.ENTUR_SONAR_PASSWORD }}
SONAR_HOST_URL: https://sonarcloud.io
with:
args: >
-Dsonar.organization=enturas-github
-Dsonar.projectKey=entur_abzu
-Dsonar.sources=src
-Dsonar.tests=src
-Dsonar.test.inclusions=src/**/*.test.ts
-Dsonar.typescript.lcov.reportPaths=coverage/lcov.info
- run: npm run build
env:
REACT_APP_VERSION: ${{ github.sha }}
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: |
build
runs-on: ubuntu-latest
jobs:
deploy_dev:
runs-on: ubuntu-latest
needs: [build]
environment: 'dev'
steps:
- uses: actions/checkout@v4
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
name: build
path: build
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy favicon
run: cp build/nsr-d.ico build/favicon.ico
- name: Copy bootstrap config
Expand All @@ -77,12 +32,16 @@ jobs:
target: dev
deploy_nordic_dev:
runs-on: ubuntu-latest
needs: [build]
environment: 'dev'
steps:
- uses: actions/checkout@v4
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
name: build
path: build
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy favicon
run: cp build/nsr-d.ico build/favicon.ico
- name: Copy bootstrap config
Expand All @@ -102,6 +61,11 @@ jobs:
- uses: actions/checkout@v4
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
name: build
path: build
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy favicon
run: cp build/nsr-s.ico build/favicon.ico
- name: Copy bootstrap config
Expand All @@ -121,6 +85,11 @@ jobs:
- uses: actions/checkout@v4
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
name: build
path: build
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy favicon
run: cp build/nsr-p.ico build/favicon.ico
- name: Copy bootstrap config
Expand Down

0 comments on commit 61a930b

Please sign in to comment.