-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate the CI from Google Cloud Build to Github Actions: 1. adds a RBAC so we can make the permissions the CI has access to very tight 2. migrate to Artifacts Registry which allows for scoping projects (and thus tighter permissions) 3. we like Github Actions better in terms of developer experience :slightly_smiling_face: 4. unify the way code is deployed at @poki
- Loading branch information
Showing
8 changed files
with
138 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,71 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.3' | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn lint | ||
- run: yarn cucumber | ||
env: | ||
DOCKER_HOST: unix:///var/run/docker.sock | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: GCP auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | ||
- name: 'Set up Cloud SDK' | ||
uses: google-github-actions/setup-gcloud@v2 | ||
- name: Configure docker for GCP | ||
run: gcloud auth configure-docker europe-docker.pkg.dev | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: europe-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/netlib/signaling:${{ github.sha }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
- test | ||
timeout-minutes: 30 | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: GCP auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | ||
- name: 'Set up Cloud SDK' | ||
uses: google-github-actions/setup-gcloud@v2 | ||
- uses: google-github-actions/get-gke-credentials@v2 | ||
with: | ||
cluster_name: production-eu-west-4 | ||
location: europe-west4-a | ||
- name: Install SOPS | ||
run: |- | ||
curl -LO https://github.com/getsops/sops/releases/download/v3.8.1/sops-v3.8.1.linux.amd64 | ||
chmod +x sops-v3.8.1.linux.amd64 | ||
sudo mv sops-v3.8.1.linux.amd64 /usr/local/bin/sops | ||
- name: Apply secrets | ||
run: sops --decrypt "manifest/secrets.yaml" | kubectl apply --validate -f - | ||
- name: Deploy | ||
run: kubectl kustomize "manifest" | envsubst | kubectl apply --validate -f - |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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,62 @@ | ||
# this file needs permissions to be applied, which can be manually done with | ||
# kubectl apply --validate -f manifest/rbac.yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
namespace: netlib | ||
name: netlib-ci | ||
rules: | ||
- apiGroups: [""] | ||
resources: | ||
- secrets | ||
- services | ||
verbs: | ||
- get | ||
- update | ||
- create | ||
- patch | ||
- apiGroups: ["apps"] | ||
resources: | ||
- deployments | ||
verbs: | ||
- get | ||
- update | ||
- create | ||
- patch | ||
- apiGroups: ["networking.k8s.io"] | ||
resources: | ||
- ingresses | ||
verbs: | ||
- get | ||
- update | ||
- create | ||
- patch | ||
- apiGroups: ["cloud.google.com"] | ||
resources: | ||
- backendconfigs | ||
verbs: | ||
- get | ||
- update | ||
- create | ||
- patch | ||
- apiGroups: ["networking.gke.io"] | ||
resources: | ||
- managedCertificates | ||
verbs: | ||
- get | ||
- update | ||
- create | ||
- patch | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: netlib-ci | ||
namespace: netlib | ||
subjects: | ||
- kind: User | ||
name: [email protected] | ||
roleRef: | ||
kind: Role | ||
name: netlib-ci | ||
apiGroup: rbac.authorization.k8s.io |
This file contains 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