Skip to content
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

Add permissions for each deploy step #747

Merged
merged 6 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ jobs:
needs: build
environment: staging

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

steps:
- name: Checkout
Expand All @@ -88,14 +95,11 @@ jobs:

- name: Tag build and push to ECR
run: |
docker pull ${{ vars.ECR_URL }}:$SHA
docker tag ${{ vars.ECR_URL }}:$SHA ${{ vars.ECR_URL }}:staging.latest
docker push ${{ vars.ECR_URL }}:staging.latest

- name: Authenticate to the cluster
env:
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
run: |
echo "${KUBE_CERT}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
Expand All @@ -106,7 +110,7 @@ jobs:
- name: Rollout restart deployment
run: |
kubectl set image -n ${KUBE_NAMESPACE} \
config/kubernetes/staging \
deployment/disclosure-checker-staging \
webapp="${{ vars.ECR_URL }}:$SHA"

- name: Send deploy notification to product Slack channel
Expand Down Expand Up @@ -144,8 +148,15 @@ jobs:
needs: build
environment: qa

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

steps:
- name: Checkout
Expand All @@ -171,14 +182,11 @@ jobs:

- name: Tag build and push to ECR
run: |
docker pull ${{ vars.ECR_URL }}:$SHA
docker tag ${{ vars.ECR_URL }}:$SHA ${{ vars.ECR_URL }}:qa.latest
docker push ${{ vars.ECR_URL }}:qa.latest

- name: Authenticate to the cluster
env:
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
run: |
echo "${KUBE_CERT}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
Expand All @@ -189,7 +197,7 @@ jobs:
- name: Rollout restart deployment
run: |
kubectl set image -n ${KUBE_NAMESPACE} \
config/kubernetes/qa \
deployment/disclosure-checker-qa \
webapp="${{ vars.ECR_URL }}:$SHA"

- name: Send deploy notification to product Slack channel
Expand Down Expand Up @@ -228,8 +236,15 @@ jobs:
if: ${{ github.ref == 'refs/heads/main' }}
environment: production

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
KUBE_NAMESPACE: ${{ secrets.KUBE_PROD_NAMESPACE }}
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

steps:
- name: Checkout
Expand All @@ -255,14 +270,11 @@ jobs:

- name: Tag build and push to ECR
run: |
docker pull ${{ vars.ECR_URL }}:$SHA
docker tag ${{ vars.ECR_URL }}:$SHA ${{ vars.ECR_URL }}:production.latest
docker push ${{ vars.ECR_URL }}:production.latest

- name: Authenticate to the cluster
env:
KUBE_CERT: ${{ secrets.KUBE_PROD_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_PROD_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_PROD_CLUSTER }}
run: |
echo "${KUBE_CERT}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
Expand All @@ -273,7 +285,7 @@ jobs:
- name: Rollout restart deployment
run: |
kubectl set image -n ${KUBE_NAMESPACE} \
config/kubernetes/production \
deployment/disclosure-checker-production \
webapp="${{ vars.ECR_URL }}:$SHA"

- name: Send deploy notification to product Slack channel
Expand Down
4 changes: 2 additions & 2 deletions config/kubernetes/production/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: disclosure-checker-deployment-production
name: disclosure-checker-production
namespace: disclosure-checker-production
spec:
replicas: 2
replicas: 3
revisionHistoryLimit: 5
strategy:
type: RollingUpdate
Expand Down
8 changes: 4 additions & 4 deletions config/kubernetes/qa/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: disclosure-checker-deployment-qa
name: disclosure-checker-qa
namespace: disclosure-checker-qa
spec:
replicas: 2
replicas: 1
revisionHistoryLimit: 5
strategy:
type: RollingUpdate
Expand Down Expand Up @@ -35,7 +35,7 @@ spec:
memory: 1Gi
readinessProbe:
httpGet:
path: /ping.json
path: /health
port: 3000
httpHeaders:
- name: X-Forwarded-Proto
Expand All @@ -46,7 +46,7 @@ spec:
periodSeconds: 10
livenessProbe:
httpGet:
path: /ping.json
path: /health
port: 3000
httpHeaders:
- name: X-Forwarded-Proto
Expand Down
4 changes: 2 additions & 2 deletions config/kubernetes/staging/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: disclosure-checker-deployment-staging
name: disclosure-checker-staging
namespace: disclosure-checker-staging
spec:
replicas: 2
replicas: 1
revisionHistoryLimit: 5
strategy:
type: RollingUpdate
Expand Down
Loading