From a3758769977158135f850f6903c715cf748a8e6a Mon Sep 17 00:00:00 2001 From: HARPER Jon Date: Tue, 18 Mar 2025 10:39:16 +0100 Subject: [PATCH 1/3] add build-frontend-app-generic.yml As part of this move, the build uses environment secrets for pushing the docker image "latest" when a PR is merged in main From the build.yml of our apps, and then made more similar to release-frontend-app-generic.yml Signed-off-by: HARPER Jon --- .../workflows/build-frontend-app-generic.yml | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/build-frontend-app-generic.yml diff --git a/.github/workflows/build-frontend-app-generic.yml b/.github/workflows/build-frontend-app-generic.yml new file mode 100644 index 0000000..a75401f --- /dev/null +++ b/.github/workflows/build-frontend-app-generic.yml @@ -0,0 +1,98 @@ +on: + workflow_call: + inputs: + dockerImage: + description: 'Name of the Docker image (e.g., organization/app-name)' + required: true + type: string + dockerUsername: + required: true + type: string + eventOrganizations: + required: false + default: '' + type: string + eventType: + required: true + type: string + environment: + required: false + default: 'release' + type: string + licensercPath: + required: false + default: '' + type: string + secrets: + sonar-token: + required: true + DOCKERHUB_TOKEN: + required: true + repo-token: + required: true + +env: + NODE_OPTIONS: '--max_old_space_size=4096' + +jobs: + license-headers: + if: ${{ inputs.licensercPath != '' }} + name: Check licenses headers + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 v4.2.2 + with: + persist-credentials: false + + - name: Check License Header (Check Mode) + uses: apache/skywalking-eyes/header@6b2529214f6b1ccee3ec92bb0adfeabf6f66f538 # v0.5.0 + with: + config: ${{ inputs.licensercPath }} + + build: + runs-on: ubuntu-latest + environment: + name: ${{ github.ref == 'refs/heads/main' && inputs.environment || '' }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 v4.3.0 + with: + node-version: 22 + + - name: Install Dependencies + run: npm ci + + - name: Quality Checks + run: | + npm run lint + npm run test:coverage + npm run licenses-check + + - name: Build Application + run: npm run build + + - name: SonarCloud Analysis + uses: SonarSource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b # v3.0.0 + env: + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + SONAR_TOKEN: ${{ secrets.sonar-token }} + + - name: Build and publish Docker image - Main + if: github.ref == 'refs/heads/main' + uses: elgohr/Publish-Docker-Github-Action@33a481be3e179353cb7793a92b57cf9a6c985860 # v4 + with: + name: ${{ inputs.dockerImage }} + username: ${{ inputs.dockerUsername }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Broadcast update event + if: github.ref == 'refs/heads/main' + uses: gridsuite/broadcast-event@67201bc793618876822097ce2152b23b496a8227 # main + with: + token: ${{ secrets.repo-token }} + organizations: ${{ inputs.eventOrganizations }} + event-type: ${{ inputs.eventType }} From 0d835cd2476114f8ebe20e9cfd490818c98a0be6 Mon Sep 17 00:00:00 2001 From: Tristan <135599584+Tristan-WorkGH@users.noreply.github.com> Date: Thu, 20 Mar 2025 12:16:06 +0100 Subject: [PATCH 2/3] lint already done during build Signed-off-by: Tristan <135599584+Tristan-WorkGH@users.noreply.github.com> --- .github/workflows/build-frontend-app-generic.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-frontend-app-generic.yml b/.github/workflows/build-frontend-app-generic.yml index a75401f..a1e1982 100644 --- a/.github/workflows/build-frontend-app-generic.yml +++ b/.github/workflows/build-frontend-app-generic.yml @@ -68,7 +68,6 @@ jobs: - name: Quality Checks run: | - npm run lint npm run test:coverage npm run licenses-check From 310fad5e8196f5ca997732226867b5ff2e9ffb1a Mon Sep 17 00:00:00 2001 From: HARPER Jon Date: Fri, 21 Mar 2025 16:07:24 +0100 Subject: [PATCH 3/3] fixup Signed-off-by: HARPER Jon --- .github/workflows/build-frontend-app-generic.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-frontend-app-generic.yml b/.github/workflows/build-frontend-app-generic.yml index a1e1982..4523010 100644 --- a/.github/workflows/build-frontend-app-generic.yml +++ b/.github/workflows/build-frontend-app-generic.yml @@ -56,7 +56,7 @@ jobs: name: ${{ github.ref == 'refs/heads/main' && inputs.environment || '' }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 v4.2.2 with: persist-credentials: false - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 v4.3.0 @@ -77,7 +77,6 @@ jobs: - name: SonarCloud Analysis uses: SonarSource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b # v3.0.0 env: - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} SONAR_TOKEN: ${{ secrets.sonar-token }} - name: Build and publish Docker image - Main