diff --git a/.github/workflows/build-previews.yml b/.github/workflows/build-previews.yml index 2fbcd037..e9b9c1ac 100644 --- a/.github/workflows/build-previews.yml +++ b/.github/workflows/build-previews.yml @@ -1,39 +1,39 @@ -name: 'Netlify Preview Deploy' +name: Netlify Preview Deploy on: pull_request: types: ['opened', 'edited', 'synchronize'] +concurrency: + group: preview-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: deploy: name: 'Deploy' runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x] steps: - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} - - uses: actions/cache@v4 + fetch-depth: 0 + + - name: Prepare Deploy + uses: ./.github/actions/prepare-deploy with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: npm ci for website - run: npm ci - working-directory: website - - run: npm run build -- --output-hashing=none --base-href=/ - working-directory: website + main-branch-name: develop + app-configuration: preview - - uses: jsmrcaga/action-netlify-deploy@master + - name: Publish + id: deploy + uses: netlify/actions/cli@master with: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + args: deploy --dir=deploy --filter=ftu-ui + env: NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - install_command: false - build_command: false - build_directory: website/dist/a2agc + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + + - name: Create Deploy Comment + uses: ./.github/actions/deploy-comment + with: + deploy-url: ${{steps.deploy.outputs.NETLIFY_URL}} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..86893cc6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + branches: + - main + - develop + pull_request: + +concurrency: + group: ci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + main: + name: Nx Cloud - Main Job + uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.11.2 + with: + number-of-agents: 3 + init-commands: | + npx nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3 + parallel-commands: | + npx nx-cloud record -- npx nx workspace-lint + npx nx-cloud record -- npx nx format:check + parallel-commands-on-agents: | + npx nx affected --target=lint --parallel=3 + npx nx affected --target=test --parallel=3 --ci --code-coverage + npx nx affected --target=test-doc-coverage --parallel=3 + npx nx affected --target=build --parallel=3 + main-branch-name: develop + + agents: + name: Nx Cloud - Agents + uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.11.2 + with: + number-of-agents: 3 + + slack-notification: + name: Slack Notification + if: ${{ always() }} + runs-on: ubuntu-latest + needs: main + steps: + - uses: kpritam/slack-job-status-action@v1 + with: + job-status: ${{ needs.main.result }} + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} + channel: github \ No newline at end of file diff --git a/.github/workflows/production-build.yml b/.github/workflows/production-build.yml index 5d7f02e6..6f40d143 100644 --- a/.github/workflows/production-build.yml +++ b/.github/workflows/production-build.yml @@ -1,41 +1,33 @@ -name: 'Production Build' +name: Staging Build on: workflow_run: - workflows: ['Tests'] + workflows: ['CI'] branches: ['main'] types: - completed jobs: deploy: - name: 'Deploy' if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x] steps: - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} - - uses: actions/cache@v4 + ref: main + fetch-depth: 0 + + - name: Prepare Deploy + uses: ./.github/actions/prepare-deploy with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: npm ci for website - run: npm ci - working-directory: website - - run: npm run build -- --output-hashing=none --base-href=/ - working-directory: website + main-branch-name: main + app-configuration: production + nx-command: run-many - - uses: peaceiris/actions-gh-pages@v3 + - name: Publish + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: website/dist/a2agc - commit_message: "Production deploy -- ${{ github.event.head_commit.message }}" + publish_dir: deploy + commit_message: 'Staging deploy -- ${{ github.event.head_commit.message }}' \ No newline at end of file diff --git a/.github/workflows/staging-build.yml b/.github/workflows/staging-build.yml index 335fb71f..b53a4b82 100644 --- a/.github/workflows/staging-build.yml +++ b/.github/workflows/staging-build.yml @@ -1,42 +1,34 @@ -name: 'Staging Build' +name: Staging Build on: workflow_run: - workflows: ['Tests'] + workflows: ['CI'] branches: ['develop'] types: - completed jobs: deploy: - name: 'Deploy' if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x] steps: - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} - - uses: actions/cache@v4 + ref: develop + fetch-depth: 0 + + - name: Prepare Deploy + uses: ./.github/actions/prepare-deploy with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: npm ci for website - run: npm ci - working-directory: website - - run: npm run build -- --output-hashing=none --base-href=/ - working-directory: website + main-branch-name: develop + app-configuration: staging + nx-command: run-many - - uses: peaceiris/actions-gh-pages@v3 + - name: Publish + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: website/dist/a2agc + publish_dir: deploy publish_branch: staging - commit_message: "Staging deploy -- ${{ github.event.head_commit.message }}" + commit_message: 'Staging deploy -- ${{ github.event.head_commit.message }}' \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 1f21e90c..00000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: 'Tests' - -on: - push: - branches: - - main - - develop - pull_request: - types: ['opened', 'edited', 'synchronize'] - -jobs: - tests: - name: 'Tests' - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - uses: actions/cache@v4 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: npm ci for website - run: npm ci - working-directory: website - - run: npm run lint - working-directory: website - - run: npm run test - working-directory: website - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master - with: - projectBaseDir: website - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Slack Notification - if: always() - uses: kpritam/slack-job-status-action@v1 - with: - job-status: ${{ job.status }} - slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} - channel: github