diff --git a/.github/actions/pnpm-cache-build/action.yml b/.github/actions/pnpm-cache-build/action.yml index e8c06fa4..bb492484 100644 --- a/.github/actions/pnpm-cache-build/action.yml +++ b/.github/actions/pnpm-cache-build/action.yml @@ -39,7 +39,7 @@ runs: key-4: ${{ github.sha }} with: path: | - ${{ github.workspace }}/app/client/apps/goat/.next + ${{ github.workspace }}/apps/goat/.next **/.turbo/** **/dist/** key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}-${{ env.key-4 }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 00000000..99641557 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,76 @@ +name: "Checks" + +on: + workflow_call: + outputs: + client-goat: + description: "Client goat changed" + value: ${{ jobs.checks.outputs.client-goat }} + + keycloak-theme: + description: "Keycloak theme changed" + value: ${{ jobs.checks.outputs.keycloak-theme }} + + storybook: + description: "Storybook changed" + value: ${{ jobs.checks.outputs.storybook }} + + sha-short: + description: "Short sha" + value: ${{ jobs.checks.outputs.sha-short }} + +jobs: + checks: + name: checks + runs-on: ubuntu-latest + timeout-minutes: 3 + permissions: + pull-requests: read + contents: read + steps: + - name: 📥 Checkout + uses: actions/checkout@v4 + + - name: 📥 Checkout PR + uses: ./.github/actions/pr-git-checkout + + - name: 🕵️ Detect changes + uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + client-goat: + - 'apps/goat/**' + - 'packages/**' + - '.prettier*' + - 'pnpm-lock.yaml' + + keycloak-theme: + - 'packages/keycloak-theme/**' + - 'packages/eslint-config-p4b/**' + - 'packages/prettier-config/**' + - 'packages/tsconfig/**' + - 'packages/types/**' + - 'packages/ui/**' + - '.prettier*' + - 'pnpm-lock.yaml' + + storybook: + - 'apps/storybook/**' + - 'packages/ui/**' + - 'packages/eslint-config-p4b/**' + - 'packages/prettier-config/**' + - 'packages/tsconfig/**' + - 'packages/types/**' + - '.prettier*' + - 'pnpm-lock.yaml' + + - name: 🕵️ Set sha-short + id: sha-short + run: echo "sha-short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + outputs: + client-goat: ${{ steps.changes.outputs.client-goat }} + keycloak-theme: ${{ steps.changes.outputs.keycloak-theme }} + storybook: ${{ steps.changes.outputs.storybook }} + sha-short: ${{ steps.sha-short.outputs.sha-short }} diff --git a/.github/workflows/keycloak-build.yml b/.github/workflows/keycloak-build.yml new file mode 100644 index 00000000..47b061ff --- /dev/null +++ b/.github/workflows/keycloak-build.yml @@ -0,0 +1,57 @@ +name: "Keycloak Theme Build" + +on: + workflow_call: + inputs: + keycloak-theme-artifact-id: + description: "Keycloak theme artifact id" + required: false + type: string + default: "p4b-keycloak-theme" + + push: + description: "Push to S3" + required: false + type: boolean + default: false + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: 📥 Checkout + uses: actions/checkout@v4 + + - name: 📥 Checkout PR + uses: goat-community/.github/.github/actions/pr-git-checkout@main + + - name: 📥 Monorepo install + uses: goat-community/.github/.github/actions/pnpm-install@main + with: + enable-corepack: true + cwd: ${{ github.workspace }} + + - name: 🏗️ Keycloak build + shell: bash + run: | + cd ${{github.workspace}}/packages/keycloak-theme + KEYCLOAKIFY_ARTIFACT_ID="${{ github.event.inputs.keycloak-theme-artifact-id }}" KEYCLOAKIFY_GROUP_ID="com.plan4better.auth.keycloak" pnpm run build-keycloak-theme + mv build_keycloak/target/*.jar build_keycloak/target/${{github.event.inputs.keycloak-theme-artifact-id}}.jar + + + - uses: aws-actions/configure-aws-credentials@v1 + name: 📥 Configure AWS credentials + if: ${{ github.event.inputs.push }} + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-central-1 + + - name: + if: ${{ github.event.inputs.push }} + shell: bash + run: | + cd ${{github.workspace}}/packages/keycloak-theme + aws s3 cp build_keycloak/target/${{github.event.inputs.keycloak-theme-artifact-id}}.jar s3://plan4better-assets/other/keycloak/ + \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ce740713..d89088ab 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -20,13 +20,15 @@ on: merge_group: workflow_dispatch: - concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true - jobs: + file-changes: + name: file-changes + uses: ./.github/workflows/checks.yml + secrets: inherit pr-base: name: pr-base @@ -46,21 +48,26 @@ jobs: name: lint uses: ./.github/workflows/lint.yml secrets: inherit - - build: - name: build + build-goat: + name: build + if: ${{ needs.file-changes.outputs.client-goat == 'true' || needs.file-changes.outputs.storybook == 'true' }} uses: ./.github/workflows/production-build.yml secrets: inherit - analyze: - name: analyze - needs: build + analyze-goat: + name: analyze-goat + needs: build-goat uses: ./.github/workflows/nextjs-bundle-analysis.yml secrets: inherit - + + build-keycloak: + name: build-keycloak + if: ${{ needs.file-changes.outputs.keycloak-theme == 'true' }} + uses: ./.github/workflows/keycloak-build.yml + required: - needs: [lint, typecheck, build] + needs: [lint, typecheck, build-goat, analyze-goat, build-keycloak] if: always() runs-on: ubuntu-latest steps: diff --git a/.github/workflows/production-build.yml b/.github/workflows/production-build.yml index f83190c4..1ee91171 100644 --- a/.github/workflows/production-build.yml +++ b/.github/workflows/production-build.yml @@ -22,7 +22,7 @@ jobs: enable-corepack: true cwd: ${{ github.workspace }} - - name: 🏗️ Monorepo build + - name: 🏗️ GOAT build uses: ./.github/actions/pnpm-cache-build with: cwd: ${{ github.workspace }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0790532f..ef90cb73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,6 @@ name: "Release" on: push: - branches: [main] workflow_dispatch: concurrency: @@ -10,8 +9,14 @@ concurrency: cancel-in-progress: true jobs: - release-docker: - name: release + file-changes: + name: file-changes + uses: ./.github/workflows/checks.yml + secrets: inherit + + release-docker-goat: + name: release-docker-goat + if: ${{ needs.file-changes.outputs.client-goat == 'true' }} uses: goat-community/.github/.github/workflows/reusable-docker-build.yml@main permissions: contents: read @@ -27,3 +32,32 @@ jobs: file: ${{ github.workspace }}/apps/goat/Dockerfile image-names: | goatcommunity/goat-frontend + + release-docker-storybook: + name: release-docker-storybook + if: ${{ needs.file-changes.outputs.storybook == 'true' }} + uses: goat-community/.github/.github/workflows/reusable-docker-build.yml@main + permissions: + contents: read + packages: write + pull-requests: write + secrets: + dockerhub-username: ${{ secrets.DOCKER_USERNAME }} + dockerhub-token: ${{ secrets.DOCKER_PASSWORD }} + with: + dockerhub-enable: true + ghcr-enable: false + push: ${{ github.event_name != 'pull_request' }} + file: ${{ github.workspace }}/apps/storybook/Dockerfile + image-names: | + goatcommunity/goat-storybook + + + release-keycloak-theme: + name: release-keycloak-theme + if: ${{ needs.file-changes.outputs.keycloak-theme == 'true' }} + uses: ./.github/workflows/keycloak-build.yml + secrets: inherit + with: + keycloak-theme-artifact-id: "p4b-keyclok-theme-${{ needs.file-changes.outputs.sha-short}}" + push: true diff --git a/apps/storybook/package.json b/apps/storybook/package.json index 5716e0b0..3bf6566c 100644 --- a/apps/storybook/package.json +++ b/apps/storybook/package.json @@ -5,7 +5,8 @@ "scripts": { "clean": "rimraf ./.next ./out ./coverage ./tsconfig.tsbuildinfo ./node_modules", "dev": "storybook dev -p 6006", - "typecheck": "tsc --project ./tsconfig.json --pretty --noEmit" + "typecheck": "tsc --project ./tsconfig.json --pretty --noEmit", + "build": "storybook build" }, "dependencies": { "@p4b/keycloak-theme": "*", diff --git a/packages/keycloak-theme/src/stories/Error.stories.tsx b/packages/keycloak-theme/src/stories/Error.stories.tsx index 3c72a2e0..92defa1a 100644 --- a/packages/keycloak-theme/src/stories/Error.stories.tsx +++ b/packages/keycloak-theme/src/stories/Error.stories.tsx @@ -20,3 +20,4 @@ export const WithAnotherMessage: StoryFn = () => ( }} /> ); +