-
Notifications
You must be signed in to change notification settings - Fork 46
Adding basic CICD, commenting out old CICD, disabling nx cloud #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
23ac031
Adding basic CICD, commenting out old CICD, disabling nx cloud
SamNie2027 144e9ed
Changed runner
SamNie2027 70101c4
Implementing feedback
SamNie2027 cb785a2
Update lint.yml
SamNie2027 c05b955
remove task, update readme
maxn990 d3280a4
test fetch depth fix
maxn990 2d6ea98
test commit
maxn990 3b65b23
bug fix
maxn990 de86bf7
Update auth.controller.spec.ts
maxn990 af3c373
fix tests
maxn990 0a1936f
Merge branch 'main' into New-CICD
maxn990 cbdf6e1
Trailing new line
SamNie2027 54f2a87
Merge branch 'New-CICD' of https://github.com/Code-4-Community/scaffo…
SamNie2027 a3b9d51
Update yarn.lock
maxn990 cdb6a45
Merge remote-tracking branch 'origin/main' into New-CICD
maxn990 6049044
Update yarn.lock
maxn990 5305b3d
Merge branch 'main' into New-CICD
maxn990 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Backend build | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
| branches: ['main'] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Use NodeJS 24.x | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.x | ||
| cache: 'yarn' | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
|
|
||
| echo "AWS_SECRET_ACCESS_KEY=dummy" >> .env | ||
| echo "AWS_ACCESS_KEY_ID=dummy" >> .env | ||
| echo "AWS_REGION=us-east-2" >> .env | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn install | ||
|
|
||
| - name: Build backend | ||
| run: npx nx build backend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,113 +1,118 @@ | ||
| name: CI/CD | ||
|
|
||
| # First runs linter and tests all affected projects | ||
| # Then, for each project that requires deployment, deploy-<project>-<service-type> is added | ||
| # Environment variables are labelled <project-name>_SHORT_DESCRIPTION | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
| branches: ['main'] | ||
| workflow_dispatch: | ||
| inputs: | ||
| manual-deploy: | ||
| description: 'App to Deploy' | ||
| required: false | ||
| default: '' | ||
|
|
||
| concurrency: | ||
| # Never have two deployments happening at the same time (potential race condition) | ||
| group: '{{ github.head_ref || github.ref }}' | ||
|
|
||
| jobs: | ||
| pre-deploy: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| affected: ${{ steps.should-deploy.outputs.affected }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| # We need to fetch all branches and commits so that Nx affected has a base to compare against. | ||
| fetch-depth: 0 | ||
| - name: Use Node.js 20 | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 20.x | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn install | ||
|
|
||
| # In any subsequent steps within this job (myjob) we can reference the resolved SHAs | ||
| # using either the step outputs or environment variables: | ||
| - name: Derive appropriate SHAs for base and head for `nx affected` commands | ||
| uses: nrwl/nx-set-shas@v3 | ||
|
|
||
| - run: | | ||
| echo "BASE: ${{ env.NX_BASE }}" | ||
| echo "HEAD: ${{ env.NX_HEAD }}" | ||
|
|
||
| - name: Nx Affected Lint | ||
| run: npx nx affected -t lint | ||
|
|
||
| # - name: Nx Affected Test | ||
| # run: npx nx affected -t test | ||
|
|
||
| - name: Nx Affected Build | ||
| run: npx nx affected -t build | ||
|
|
||
| - name: Determine who needs to be deployed | ||
| id: should-deploy | ||
| run: | | ||
| echo "The following projects have been affected: [$(npx nx print-affected -t build --select=tasks.target.project)]"; | ||
| echo "affected=$(npx nx print-affected -t build --select=tasks.target.project)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| deploy-debug: | ||
| needs: pre-deploy | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Debug logs | ||
| run: | | ||
| echo "Manual Deploy: ${{github.event.inputs.manual-deploy}}"; | ||
| echo "Affected Names: ${{needs.pre-deploy.outputs.affected}}"; | ||
| echo "Event: ${{github.event_name}}"; | ||
| echo "Ref: ${{github.ref}}"; | ||
| echo "Will deploy?: ${{(github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'}}"; | ||
|
|
||
| deploy-frontend: | ||
| needs: pre-deploy | ||
| if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-frontend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-frontend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-latest | ||
| # For "simplicity", deployment settings are configured in the AWS Amplify Console | ||
| # This just posts to a webhook telling Amplify to redeploy the main branch | ||
| steps: | ||
| - name: Tell Amplify to rebuild | ||
| run: curl -X POST -d {} ${C4C_OPS_WEBHOOK_DEPLOY} -H "Content-Type:application/json" | ||
| env: | ||
| C4C_OPS_WEBHOOK_DEPLOY: ${{ secrets.C4C_OPS_WEBHOOK_DEPLOY }} | ||
|
|
||
| deploy-backend: | ||
| needs: pre-deploy | ||
| if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-backend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-backend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Use Node.js 16 | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 16.x | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn install | ||
|
|
||
| - run: npx nx build c4c-ops-backend --configuration production | ||
| - name: default deploy | ||
| uses: appleboy/lambda-action@master | ||
| with: | ||
| aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| aws_region: ${{ secrets.AWS_REGION }} | ||
| function_name: c4c-ops-monolith-lambda | ||
| source: dist/apps/c4c-ops/c4c-ops-backend/main.js | ||
| # Note: | ||
| # This CICD requires AWS Amplify to be setup which tends to not be the case until the app is close to being deployed | ||
| # Therefore this is not useful for a the beginning chunk of development where everything is tested locally | ||
| # Therefore other pipelines have been made to test things locally, but once AWS Amplify is setup this can be used. | ||
|
|
||
| # name: Legacy CI/CD | ||
|
|
||
| # # First runs linter and tests all affected projects | ||
| # # Then, for each project that requires deployment, deploy-<project>-<service-type> is added | ||
| # # Environment variables are labelled <project-name>_SHORT_DESCRIPTION | ||
|
|
||
| # on: | ||
| # push: | ||
| # branches: ['main'] | ||
| # pull_request: | ||
| # branches: ['main'] | ||
| # workflow_dispatch: | ||
| # inputs: | ||
| # manual-deploy: | ||
| # description: 'App to Deploy' | ||
| # required: false | ||
| # default: '' | ||
|
|
||
| # concurrency: | ||
| # # Never have two deployments happening at the same time (potential race condition) | ||
| # group: '{{ github.head_ref || github.ref }}' | ||
|
|
||
| # jobs: | ||
| # pre-deploy: | ||
| # runs-on: ubuntu-latest | ||
| # outputs: | ||
| # affected: ${{ steps.should-deploy.outputs.affected }} | ||
| # steps: | ||
| # - uses: actions/checkout@v3 | ||
| # with: | ||
| # # We need to fetch all branches and commits so that Nx affected has a base to compare against. | ||
| # fetch-depth: 0 | ||
| # - name: Use Node.js 20 | ||
| # uses: actions/setup-node@v3 | ||
| # with: | ||
| # node-version: 20.x | ||
| # cache: 'yarn' | ||
|
|
||
| # - name: Install Dependencies | ||
| # run: yarn install | ||
|
|
||
| # # In any subsequent steps within this job (myjob) we can reference the resolved SHAs | ||
| # # using either the step outputs or environment variables: | ||
| # - name: Derive appropriate SHAs for base and head for `nx affected` commands | ||
| # uses: nrwl/nx-set-shas@v3 | ||
|
|
||
| # - run: | | ||
| # echo "BASE: ${{ env.NX_BASE }}" | ||
| # echo "HEAD: ${{ env.NX_HEAD }}" | ||
|
|
||
| # - name: Nx Affected Lint | ||
| # run: npx nx affected -t lint | ||
|
|
||
| # # - name: Nx Affected Test | ||
| # # run: npx nx affected -t test | ||
|
|
||
| # - name: Nx Affected Build | ||
| # run: npx nx affected -t build | ||
|
|
||
| # - name: Determine who needs to be deployed | ||
| # id: should-deploy | ||
| # run: | | ||
| # echo "The following projects have been affected: [$(npx nx print-affected -t build --select=tasks.target.project)]"; | ||
| # echo "affected=$(npx nx print-affected -t build --select=tasks.target.project)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # deploy-debug: | ||
| # needs: pre-deploy | ||
| # runs-on: ubuntu-latest | ||
| # steps: | ||
| # - name: Debug logs | ||
| # run: | | ||
| # echo "Manual Deploy: ${{github.event.inputs.manual-deploy}}"; | ||
| # echo "Affected Names: ${{needs.pre-deploy.outputs.affected}}"; | ||
| # echo "Event: ${{github.event_name}}"; | ||
| # echo "Ref: ${{github.ref}}"; | ||
| # echo "Will deploy?: ${{(github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'}}"; | ||
|
|
||
| # deploy-frontend: | ||
| # needs: pre-deploy | ||
| # if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-frontend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-frontend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' | ||
| # runs-on: ubuntu-latest | ||
| # # For "simplicity", deployment settings are configured in the AWS Amplify Console | ||
| # # This just posts to a webhook telling Amplify to redeploy the main branch | ||
| # steps: | ||
| # - name: Tell Amplify to rebuild | ||
| # run: curl -X POST -d {} ${C4C_OPS_WEBHOOK_DEPLOY} -H "Content-Type:application/json" | ||
| # env: | ||
| # C4C_OPS_WEBHOOK_DEPLOY: ${{ secrets.C4C_OPS_WEBHOOK_DEPLOY }} | ||
|
|
||
| # deploy-backend: | ||
| # needs: pre-deploy | ||
| # if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-backend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-backend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' | ||
| # runs-on: ubuntu-latest | ||
| # steps: | ||
| # - uses: actions/checkout@v3 | ||
| # - name: Use Node.js 16 | ||
| # uses: actions/setup-node@v3 | ||
| # with: | ||
| # node-version: 16.x | ||
| # cache: 'yarn' | ||
|
|
||
| # - name: Install Dependencies | ||
| # run: yarn install | ||
|
|
||
| # - run: npx nx build c4c-ops-backend --configuration production | ||
| # - name: default deploy | ||
| # uses: appleboy/lambda-action@master | ||
| # with: | ||
| # aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| # aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| # aws_region: ${{ secrets.AWS_REGION }} | ||
| # function_name: c4c-ops-monolith-lambda | ||
| # source: dist/apps/c4c-ops/c4c-ops-backend/main.js | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Frontend build | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
| branches: ['main'] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Use NodeJS 24.x | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.x | ||
| cache: 'yarn' | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
|
|
||
| echo "AWS_SECRET_ACCESS_KEY=dummy" >> .env | ||
| echo "AWS_ACCESS_KEY_ID=dummy" >> .env | ||
| echo "AWS_REGION=us-east-2" >> .env | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn install | ||
|
|
||
| - name: Build frontend | ||
| run: npx nx build frontend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: Jest run | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
| branches: ['main'] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Use NodeJS 24.x | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.x | ||
| cache: 'yarn' | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
|
|
||
| echo "AWS_BUCKET_NAME=dummy" >> .env | ||
| echo "AWS_SECRET_ACCESS_KEY=dummy" >> .env | ||
| echo "AWS_ACCESS_KEY_ID=dummy" >> .env | ||
| echo "AWS_REGION=us-east-2" >> .env | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn install | ||
|
|
||
| - name: Run Jest tests | ||
| run: yarn test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: Linter run | ||
|
SamNie2027 marked this conversation as resolved.
|
||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
| branches: ['main'] | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Use Node.js 24.x | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.x | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn install | ||
|
|
||
| - name: Derive appropriate SHAs for nx affected | ||
| uses: nrwl/nx-set-shas@v4 | ||
|
|
||
| - name: Run linter | ||
| run: npx nx affected -t lint | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.