Merge pull request #961 from bakaphp/dependabot/composer/nuwave/light… #627
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
name: Deploy To GCP | |
on: | |
push: | |
branches: | |
- '1.x' | |
- 'development' | |
workflow_dispatch: | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
environment: ${{ github.ref_name }} | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
steps: | |
- id: checkout | |
name: Checkout | |
uses: actions/checkout@v4 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
token_format: 'access_token' | |
workload_identity_provider: "${{secrets.GCP_WORKLOAD_IDENTITY_PROVIDER}}" | |
service_account: "${{secrets.GCP_SERVICE_ACCOUNT}}" | |
- name: Login to Artifact Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.GOOGLE_REGISTRY }} | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- id: docker-push-tagged | |
name: Tag Docker image and push to Google Artifact Registry | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
file: ${{ github.ref_name }}.Dockerfile | |
tags: | | |
${{ secrets.GCP_IMAGE_TAG }}:${{ github.run_number }} | |
${{ secrets.GCP_IMAGE_TAG }}:latest | |
Deploy: | |
runs-on: ubuntu-latest | |
environment: ${{ github.ref_name }} | |
needs: Build | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
token_format: 'access_token' | |
workload_identity_provider: "${{secrets.GCP_WORKLOAD_IDENTITY_PROVIDER}}" | |
service_account: "${{secrets.GCP_SERVICE_ACCOUNT}}" | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
with: | |
version: '>= 363.0.0' | |
- name: Install Kubernetes toolset | |
uses: stefanprodan/[email protected] | |
with: | |
kubectl: 1.23.0 | |
- name: Download Configmap | |
run: | | |
gcloud storage cp gs://${{secrets.GCP_BUCKET_NAME}}/${{ github.ref_name }}/${{ secrets.GCP_CONFIGMAP_FILENAME }} helm/templates/envconfigmap.yaml | |
- id: 'get-credentials' | |
uses: 'google-github-actions/get-gke-credentials@v2' | |
with: | |
cluster_name: ${{ secrets.GCP_CLUSTER_NAME }} | |
location: ${{ secrets.GOOGLE_LOCATION }} | |
- name: Deploy helm chart | |
run: | | |
touch helm/.helmignore | |
echo "svc-lb.yaml" >> helm/.helmignore | |
echo "cluster-autoscaler-autodiscover.yaml" >> helm/.helmignore | |
helm upgrade --install ${{ secrets.INSTANCE_NAME }} helm \ | |
--namespace ${{ secrets.INSTANCE_NAME }} \ | |
--create-namespace \ | |
--set apiImage=${{ secrets.GCP_API_IMAGE }}:${{ github.run_number }} \ | |
--set services.loadBalancer.name=${{ secrets.GCP_LOAD_BALANCER_NAME }} \ | |
--set cert.apiDomain=${{ secrets.GCP_KANVAS_API_DOMAIN }} \ | |
--set staticIP.name=${{ secrets.GCP_STATIC_IP_NAME }} |