-
Notifications
You must be signed in to change notification settings - Fork 68
Phase 2 changes #325
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
Phase 2 changes #325
Changes from 250 commits
e2bf8bd
5d25bc9
9aa9d59
42311d3
387640e
606df3b
6f100c4
7ad2a96
f628177
36fbe94
f44cd63
ce37087
362e35f
353ecbd
57bed46
05af8cc
0eb6247
ad47d43
7c48254
0b5f0aa
b3b4115
2ec67ae
85562b1
c946422
5e04e8e
4e47d64
a9db144
e3b27f9
c44b868
7876509
1e33c7d
da05f9e
1138ff8
98f7706
5409ed4
87d303f
4b0980d
36bd338
3b4f60e
b526c2b
eb3c085
7bd14ba
e54f747
5c06e63
c175840
5429994
c95be3b
f8c0da0
9fd74a3
5af4f90
c46f6b2
60d550e
f8dea8d
d9baec9
5355b58
e61768f
6df51a8
89bf141
f528b32
b8f3482
102b652
3783c5b
c041cc3
ba0d690
091a760
9858dce
d366e77
b983191
e785f06
d06e607
0a274b5
b5f4786
6d53d54
141e915
2acbc94
6f1a997
9c56b0b
ea2ad5d
9386236
051189c
2072494
60e3843
0b5fe41
28a2b97
eef8d0a
8dabe34
c6c0e70
2733451
cd0a2b2
07327e1
66cae83
f2f0bf7
d86c140
73272d8
2af14a9
32a3316
82f1118
ff5d916
e9e6824
381dc85
87f3401
73351f5
5b1a690
1f36938
f77d3eb
d1acf7e
d43a1a7
d64d353
5788c40
c556bfe
8009af5
9951d95
0f0afd4
1daa149
f7078af
40b8c0a
3b2032d
aa303b2
c284ced
b164e7e
6ad4b6b
476cb01
cccf2ae
abd8976
9bd173d
79e5bc1
f978396
5081e6e
bc9f327
03de43c
48846dc
f8c0c47
66347d1
83b8f85
ad1d117
e67a575
aa840ab
ef8b129
5d07411
506aac4
e784a59
1cdad7b
42b6208
edda621
239f688
ba6a5e9
dadd18b
0025e67
d7ad71c
779d5fd
71fe22c
c1ee002
f31e1d9
0aa0950
cfd14cd
b003992
78b9c63
a9e8d64
20a7bfc
7b209a5
4011da2
0224649
c4c4cb1
5376918
8e35867
df71ef5
2bec9ca
bcb4254
a916952
82d830c
963c7fd
22ae653
fa2d90f
6d465d5
50948c8
24f89f6
feb8f93
448fe79
73d991e
ce37701
2c8d9aa
96cab50
1edf4bc
ba68e51
15a7ab5
1266e5c
88f6d6f
bb169f8
33ac6cc
72e8eef
dc2f7a7
19e2666
dfb85b5
633b600
e17eee1
8d7153b
967af44
20093b7
0a0e96b
0e9490e
dae1aa4
1c157f4
13844d4
1f30285
f89e649
8f1fc0d
67253f4
09ca087
ca76b24
c7077ab
2b4340e
377cb75
2c0cf2d
a805e2c
3a07a31
9da6aa8
a5d32b2
3d17492
dbdc65f
6f80a33
aff363e
bd1850e
b66e87c
741694d
766a037
586dc53
7294b95
f3f4bd6
eb1b640
2480f25
0ec3f21
b8f96cb
3064daa
f6eba62
7ceea39
84258db
32f6129
e299201
ed5c79d
39cdc1d
14904f2
b17ecda
3c45b55
2e7d300
036ecb2
49d70c1
8d66187
19fab2a
f8c0557
427fe79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,178 @@ | |||||||||||||||||
| name: Carbon Registry Demo Deployment | |||||||||||||||||
| on: | |||||||||||||||||
| push: | |||||||||||||||||
| branches: | |||||||||||||||||
| - "main" | |||||||||||||||||
| paths: | |||||||||||||||||
| - web/** | |||||||||||||||||
| - backend/** | |||||||||||||||||
| - .github/workflows/deployment* | |||||||||||||||||
|
|
|||||||||||||||||
| jobs: | |||||||||||||||||
| changes: | |||||||||||||||||
| name: Deploy Pre Check | |||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||
| outputs: | |||||||||||||||||
| backend-changes: ${{ steps.changes.outputs.backend-changes }} | |||||||||||||||||
| all-changes: ${{ steps.changes.outputs.all-changes }} | |||||||||||||||||
| workflows-changes: ${{ steps.changes.outputs.workflows-changes }} | |||||||||||||||||
| frontend-changes: ${{ steps.changes.outputs.frontend-changes }} | |||||||||||||||||
| steps: | |||||||||||||||||
| - uses: actions/checkout@v3 | |||||||||||||||||
| with: | |||||||||||||||||
| fetch-depth: 0 | |||||||||||||||||
| ref: ${{ github.event.inputs.branch_name || github.ref }} | |||||||||||||||||
| - name: Use Node.js ${{ matrix.node-version }} | |||||||||||||||||
| uses: actions/setup-node@v3 | |||||||||||||||||
| with: | |||||||||||||||||
| node-version: ${{ matrix.node-version }} | |||||||||||||||||
| - name: Determine changed services | |||||||||||||||||
| id: changes | |||||||||||||||||
| run: | | |||||||||||||||||
| CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) | |||||||||||||||||
|
|
|||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q "docker-"; then | |||||||||||||||||
| echo "All changes detected." | |||||||||||||||||
| echo "all-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||
| else | |||||||||||||||||
| echo "No All changes detected." | |||||||||||||||||
| echo "all-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||
| fi | |||||||||||||||||
|
|
|||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q ".github/workflows/"; then | |||||||||||||||||
| echo "Workflow changes detected." | |||||||||||||||||
| echo "workflows-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||
| else | |||||||||||||||||
| echo "No Workflow changes detected." | |||||||||||||||||
| echo "workflows-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||
| fi | |||||||||||||||||
|
|
|||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q "web/"; then | |||||||||||||||||
| echo "Frontend changes detected." | |||||||||||||||||
| echo "frontend-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||
| else | |||||||||||||||||
| echo "No Frontend changes detected." | |||||||||||||||||
| echo "frontend-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||
| fi | |||||||||||||||||
|
|
|||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q "backend/"; then | |||||||||||||||||
| echo "Backend changes detected." | |||||||||||||||||
| echo "backend-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||
| else | |||||||||||||||||
| echo "No Backend changes detected." | |||||||||||||||||
| echo "backend-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||
| fi | |||||||||||||||||
|
|
|||||||||||||||||
| deploy_frontend: | |||||||||||||||||
| name: Carbon Registry Frontend Deploy | |||||||||||||||||
| needs: changes | |||||||||||||||||
| if: needs.changes.outputs.frontend-changes == 'true' || needs.changes.outputs.workflows-changes == 'true' || needs.changes.outputs.all-changes == 'true' | |||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||
| concurrency: | |||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }}-'frontend' | |||||||||||||||||
| cancel-in-progress: true | |||||||||||||||||
| steps: | |||||||||||||||||
| - uses: actions/checkout@v3 | |||||||||||||||||
| with: | |||||||||||||||||
| fetch-depth: 5 | |||||||||||||||||
| - name: Check Docker variable changes | |||||||||||||||||
| run: | | |||||||||||||||||
| echo "docker-compose file Change...." | |||||||||||||||||
| git diff HEAD~ -- HEAD -z ./docker-compose* | |||||||||||||||||
| - name: Cache modules | |||||||||||||||||
| uses: actions/cache@v3 | |||||||||||||||||
| id: yarn-cache | |||||||||||||||||
| with: | |||||||||||||||||
| path: node_modules | |||||||||||||||||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |||||||||||||||||
| restore-keys: ${{ runner.os }}-yarn- | |||||||||||||||||
| - name: Configure AWS credentials | |||||||||||||||||
| uses: aws-actions/configure-aws-credentials@v1 | |||||||||||||||||
| with: | |||||||||||||||||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |||||||||||||||||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |||||||||||||||||
| aws-region: us-east-1 | |||||||||||||||||
| - name: Use Node.js ${{ matrix.node-version }} | |||||||||||||||||
| uses: actions/setup-node@v3 | |||||||||||||||||
| with: | |||||||||||||||||
| node-version: ${{ matrix.node-version }} | |||||||||||||||||
| - name: Login to Amazon ECR | |||||||||||||||||
| id: login-ecr | |||||||||||||||||
| uses: aws-actions/amazon-ecr-login@v1 | |||||||||||||||||
| - name: Build, tag, and push the image to Amazon ECR | |||||||||||||||||
| id: build-image | |||||||||||||||||
| env: | |||||||||||||||||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |||||||||||||||||
| ECR_REPOSITORY: carbon-web | |||||||||||||||||
| IMAGE_TAG: ${{ github.head_ref || github.ref_name }} | |||||||||||||||||
| run: | | |||||||||||||||||
| # Build a docker container and push it to ECR | |||||||||||||||||
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=3030 --build-arg VITE_APP_BACKEND=http://localhost:3000 --build-arg VITE_APP_COUNTRY_NAME="CountryX" --build-arg VITE_APP_REGISTRY_NAME="CountryXRegistry" --build-arg VITE_APP_MAP_TYPE="Mapbox" --build-arg VITE_APP_MAPBOXGL_ACCESS_TOKEN=${{ secrets.MAPBOXGL_ACCESS_TOKEN }} --build-arg VITE_APP_MAXIMUM_FILE_SIZE=5242880 --build-arg COUNTRY_FLAG_URL="https://carbon-common-dev.s3.amazonaws.com/flag.png" | |||||||||||||||||
| echo "Pushing image to ECR..." | |||||||||||||||||
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |||||||||||||||||
| echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |||||||||||||||||
| - name: Deploy docker image to Amazon EC2 | |||||||||||||||||
| if: github.ref == 'refs/heads/main' | |||||||||||||||||
| env: | |||||||||||||||||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |||||||||||||||||
| ECR_REPOSITORY: carbon-web | |||||||||||||||||
| IMAGE_TAG: ${{ github.head_ref || github.ref_name }} | |||||||||||||||||
| PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE_DEMO }} | |||||||||||||||||
| HOSTNAME: ${{secrets.HOST_IP_DEMO }} | |||||||||||||||||
| USER_NAME: ec2-user | |||||||||||||||||
| run: | | |||||||||||||||||
| echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |||||||||||||||||
| ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' | |||||||||||||||||
| carbon/prod_frontend_deploy.sh ' | |||||||||||||||||
|
|
|||||||||||||||||
| deploy_backend: | |||||||||||||||||
|
Comment on lines
+67
to
+128
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 9 months ago To fix the issue, we need to add a The
Suggested changeset
1
.github/workflows/deployment-demo.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||
| name: Carbon Registry Backend Deploy | |||||||||||||||||
| needs: changes | |||||||||||||||||
| if: needs.changes.outputs.backend-changes == 'true' || needs.changes.outputs.workflows-changes == 'true' || needs.changes.outputs.all-changes == 'true' | |||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||
| concurrency: | |||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }}-'backend' | |||||||||||||||||
| cancel-in-progress: true | |||||||||||||||||
| steps: | |||||||||||||||||
| - uses: actions/checkout@v3 | |||||||||||||||||
| with: | |||||||||||||||||
| fetch-depth: 5 | |||||||||||||||||
| - name: Check Docker variable changes | |||||||||||||||||
| run: | | |||||||||||||||||
| echo "docker-compose file Change...." | |||||||||||||||||
| git diff HEAD~ -- HEAD -z ./docker-compose* | |||||||||||||||||
| - name: Use Node.js ${{ matrix.node-version }} | |||||||||||||||||
| uses: actions/setup-node@v3 | |||||||||||||||||
| with: | |||||||||||||||||
| node-version: ${{ matrix.node-version }} | |||||||||||||||||
| - name: Configure AWS credentials | |||||||||||||||||
| uses: aws-actions/configure-aws-credentials@v1 | |||||||||||||||||
| with: | |||||||||||||||||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |||||||||||||||||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |||||||||||||||||
| aws-region: us-east-1 | |||||||||||||||||
| - name: Login to Amazon ECR | |||||||||||||||||
| id: login-ecr | |||||||||||||||||
| uses: aws-actions/amazon-ecr-login@v1 | |||||||||||||||||
| - name: Build, tag, and push the image to Amazon ECR | |||||||||||||||||
| id: build-image | |||||||||||||||||
| env: | |||||||||||||||||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |||||||||||||||||
| ECR_REPOSITORY: carbon-services | |||||||||||||||||
| IMAGE_TAG: ${{ github.head_ref || github.ref_name }} | |||||||||||||||||
| run: | | |||||||||||||||||
| # Build a docker container and push it to ECR | |||||||||||||||||
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f backend/services/Dockerfile . | |||||||||||||||||
| echo "Pushing image to ECR..." | |||||||||||||||||
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |||||||||||||||||
| echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |||||||||||||||||
| - name: Deploy docker image to Amazon EC2 | |||||||||||||||||
| if: github.ref == 'refs/heads/main' | |||||||||||||||||
| env: | |||||||||||||||||
| PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE_DEMO }} | |||||||||||||||||
| HOSTNAME: ${{secrets.HOST_IP_DEMO }} | |||||||||||||||||
| USER_NAME: ec2-user | |||||||||||||||||
| run: | | |||||||||||||||||
| echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |||||||||||||||||
| ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' | |||||||||||||||||
| carbon/prod_backend_deploy.sh ' | |||||||||||||||||
|
Comment on lines
+129
to
+178
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 9 months ago To fix the issue, we will add a
Suggested changeset
1
.github/workflows/deployment-demo.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,178 @@ | |||||||||||||||||||||||
| name: Carbon Registry Test Deployment | |||||||||||||||||||||||
| on: | |||||||||||||||||||||||
| push: | |||||||||||||||||||||||
| branches: | |||||||||||||||||||||||
| - '*' | |||||||||||||||||||||||
| paths: | |||||||||||||||||||||||
| - web/** | |||||||||||||||||||||||
| - backend/** | |||||||||||||||||||||||
| - .github/workflows/deployment* | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||
| changes: | |||||||||||||||||||||||
| name: Deploy Pre Check | |||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||
| outputs: | |||||||||||||||||||||||
| backend-changes: ${{ steps.changes.outputs.backend-changes }} | |||||||||||||||||||||||
| all-changes: ${{ steps.changes.outputs.all-changes }} | |||||||||||||||||||||||
| workflows-changes: ${{ steps.changes.outputs.workflows-changes }} | |||||||||||||||||||||||
| frontend-changes: ${{ steps.changes.outputs.frontend-changes }} | |||||||||||||||||||||||
| steps: | |||||||||||||||||||||||
| - uses: actions/checkout@v3 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| fetch-depth: 0 | |||||||||||||||||||||||
| ref: ${{ github.event.inputs.branch_name || github.ref }} | |||||||||||||||||||||||
| - name: Use Node.js ${{ matrix.node-version }} | |||||||||||||||||||||||
| uses: actions/setup-node@v3 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| node-version: ${{ matrix.node-version }} | |||||||||||||||||||||||
| - name: Determine changed services | |||||||||||||||||||||||
| id: changes | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q "docker-"; then | |||||||||||||||||||||||
| echo "All changes detected." | |||||||||||||||||||||||
| echo "all-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| else | |||||||||||||||||||||||
| echo "No All changes detected." | |||||||||||||||||||||||
| echo "all-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| fi | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q ".github/workflows/"; then | |||||||||||||||||||||||
| echo "Workflow changes detected." | |||||||||||||||||||||||
| echo "workflows-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| else | |||||||||||||||||||||||
| echo "No Workflow changes detected." | |||||||||||||||||||||||
| echo "workflows-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| fi | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q "web/"; then | |||||||||||||||||||||||
| echo "Frontend changes detected." | |||||||||||||||||||||||
| echo "frontend-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| else | |||||||||||||||||||||||
| echo "No Frontend changes detected." | |||||||||||||||||||||||
| echo "frontend-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| fi | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| if echo "$CHANGED_FILES" | grep -q "backend/"; then | |||||||||||||||||||||||
| echo "Backend changes detected." | |||||||||||||||||||||||
| echo "backend-changes=true" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| else | |||||||||||||||||||||||
| echo "No Backend changes detected." | |||||||||||||||||||||||
| echo "backend-changes=false" >> $GITHUB_OUTPUT | |||||||||||||||||||||||
| fi | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| deploy_frontend: | |||||||||||||||||||||||
|
Comment on lines
+13
to
+66
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 9 months ago To fix the issue, we need to add a
The
Suggested changeset
1
.github/workflows/deployment-test.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||
| name: Carbon Registry Frontend Deploy | |||||||||||||||||||||||
| needs: changes | |||||||||||||||||||||||
| if: needs.changes.outputs.frontend-changes == 'true' || needs.changes.outputs.workflows-changes == 'true' || needs.changes.outputs.all-changes == 'true' | |||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||
| concurrency: | |||||||||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }}-'frontend' | |||||||||||||||||||||||
| cancel-in-progress: true | |||||||||||||||||||||||
| steps: | |||||||||||||||||||||||
| - uses: actions/checkout@v3 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| fetch-depth: 5 | |||||||||||||||||||||||
| - name: Check Docker variable changes | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| echo "docker-compose file Change...." | |||||||||||||||||||||||
| git diff HEAD~ -- HEAD -z ./docker-compose* | |||||||||||||||||||||||
| - name: Cache modules | |||||||||||||||||||||||
| uses: actions/cache@v3 | |||||||||||||||||||||||
| id: yarn-cache | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| path: node_modules | |||||||||||||||||||||||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |||||||||||||||||||||||
| restore-keys: ${{ runner.os }}-yarn- | |||||||||||||||||||||||
| - name: Configure AWS credentials | |||||||||||||||||||||||
| uses: aws-actions/configure-aws-credentials@v1 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |||||||||||||||||||||||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |||||||||||||||||||||||
| aws-region: us-east-1 | |||||||||||||||||||||||
| - name: Use Node.js ${{ matrix.node-version }} | |||||||||||||||||||||||
| uses: actions/setup-node@v3 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| node-version: ${{ matrix.node-version }} | |||||||||||||||||||||||
| - name: Login to Amazon ECR | |||||||||||||||||||||||
| id: login-ecr | |||||||||||||||||||||||
| uses: aws-actions/amazon-ecr-login@v1 | |||||||||||||||||||||||
| - name: Build, tag, and push the image to Amazon ECR | |||||||||||||||||||||||
| id: build-image | |||||||||||||||||||||||
| env: | |||||||||||||||||||||||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |||||||||||||||||||||||
| ECR_REPOSITORY: carbon-web | |||||||||||||||||||||||
| IMAGE_TAG: ${{ github.head_ref || github.ref_name }} | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| # Build a docker container and push it to ECR | |||||||||||||||||||||||
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=3030 --build-arg VITE_APP_BACKEND=http://localhost:3000 --build-arg VITE_APP_COUNTRY_NAME="CountryX" --build-arg VITE_APP_REGISTRY_NAME="CountryXRegistry" --build-arg VITE_APP_MAP_TYPE="Mapbox" --build-arg VITE_APP_MAPBOXGL_ACCESS_TOKEN=${{ secrets.MAPBOXGL_ACCESS_TOKEN }} --build-arg VITE_APP_MAXIMUM_FILE_SIZE=5242880 --build-arg COUNTRY_FLAG_URL="https://carbon-common-dev.s3.amazonaws.com/flag.png" | |||||||||||||||||||||||
| echo "Pushing image to ECR..." | |||||||||||||||||||||||
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |||||||||||||||||||||||
| echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |||||||||||||||||||||||
| - name: Deploy docker image to Amazon EC2 | |||||||||||||||||||||||
| if: github.ref == 'refs/heads/develop' | |||||||||||||||||||||||
| env: | |||||||||||||||||||||||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |||||||||||||||||||||||
| ECR_REPOSITORY: carbon-web | |||||||||||||||||||||||
| IMAGE_TAG: ${{ github.head_ref || github.ref_name }} | |||||||||||||||||||||||
| PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE_TEST }} | |||||||||||||||||||||||
| HOSTNAME: ${{secrets.HOST_IP_TEST }} | |||||||||||||||||||||||
| USER_NAME: ec2-user | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |||||||||||||||||||||||
| ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' | |||||||||||||||||||||||
| carbon/dev_frontend_deploy.sh ' | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| deploy_backend: | |||||||||||||||||||||||
|
Comment on lines
+67
to
+128
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 9 months ago To fix the issue, we will add a
Suggested changeset
1
.github/workflows/deployment-test.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||
| name: Carbon Registry Backend Deploy | |||||||||||||||||||||||
| needs: changes | |||||||||||||||||||||||
| if: needs.changes.outputs.backend-changes == 'true' || needs.changes.outputs.workflows-changes == 'true' || needs.changes.outputs.all-changes == 'true' | |||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||
| concurrency: | |||||||||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }}-'backend' | |||||||||||||||||||||||
| cancel-in-progress: true | |||||||||||||||||||||||
| steps: | |||||||||||||||||||||||
| - uses: actions/checkout@v3 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| fetch-depth: 5 | |||||||||||||||||||||||
| - name: Check Docker variable changes | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| echo "docker-compose file Change...." | |||||||||||||||||||||||
| git diff HEAD~ -- HEAD -z ./docker-compose* | |||||||||||||||||||||||
| - name: Use Node.js ${{ matrix.node-version }} | |||||||||||||||||||||||
| uses: actions/setup-node@v3 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| node-version: ${{ matrix.node-version }} | |||||||||||||||||||||||
| - name: Configure AWS credentials | |||||||||||||||||||||||
| uses: aws-actions/configure-aws-credentials@v1 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |||||||||||||||||||||||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |||||||||||||||||||||||
| aws-region: us-east-1 | |||||||||||||||||||||||
| - name: Login to Amazon ECR | |||||||||||||||||||||||
| id: login-ecr | |||||||||||||||||||||||
| uses: aws-actions/amazon-ecr-login@v1 | |||||||||||||||||||||||
| - name: Build, tag, and push the image to Amazon ECR | |||||||||||||||||||||||
| id: build-image | |||||||||||||||||||||||
| env: | |||||||||||||||||||||||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |||||||||||||||||||||||
| ECR_REPOSITORY: carbon-services | |||||||||||||||||||||||
| IMAGE_TAG: ${{ github.head_ref || github.ref_name }} | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| # Build a docker container and push it to ECR | |||||||||||||||||||||||
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f backend/services/Dockerfile . | |||||||||||||||||||||||
| echo "Pushing image to ECR..." | |||||||||||||||||||||||
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |||||||||||||||||||||||
| echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |||||||||||||||||||||||
| - name: Deploy docker image to Amazon EC2 | |||||||||||||||||||||||
| if: github.ref == 'refs/heads/develop' | |||||||||||||||||||||||
| env: | |||||||||||||||||||||||
| PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE_TEST }} | |||||||||||||||||||||||
| HOSTNAME: ${{secrets.HOST_IP_TEST }} | |||||||||||||||||||||||
| USER_NAME: ec2-user | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |||||||||||||||||||||||
| ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' | |||||||||||||||||||||||
| carbon/dev_backend_deploy.sh ' | |||||||||||||||||||||||
|
Comment on lines
+129
to
+178
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 9 months ago To fix the issue, we need to add a The
Suggested changeset
1
.github/workflows/deployment-test.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 9 months ago
To fix the issue, we need to add a
permissionsblock to the workflow. This block should specify the minimal permissions required for the workflow to function correctly. Based on the operations performed in the workflow, thecontents: readpermission is sufficient for most jobs. For jobs that require additional permissions, such as deploying to AWS, we can add specific permissions as needed.The
permissionsblock can be added at the root level of the workflow to apply to all jobs or at the job level to customize permissions for individual jobs. In this case, we will add thepermissionsblock at the root level to ensure all jobs inherit the least privilege by default.