fix secrets #9
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
| name: Build and Deploy for Go service | |
| on: | |
| push: | |
| branches: [ development ] | |
| env: | |
| SERVICE_NAME: orphan-domain-handler | |
| NAMESPACE: kops-dev-stg | |
| CLUSTER_NAME: raramuri-tech | |
| CLUSTER_PROJECT: raramuri-tech | |
| GAR_PROJECT: raramuri-tech | |
| GAR_REGISTRY: kops-dev | |
| jobs: | |
| dockerize: | |
| runs-on: ubuntu-latest | |
| name: 🐳 Dockerize | |
| outputs: | |
| image: ${{ steps.output-image.outputs.image }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.25.1' | |
| - name: Get dependencies | |
| run: | | |
| go mod download | |
| - name: Build | |
| run: | | |
| cd ./orphan-domain-handler | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs=false -o main | |
| - name: Login to GAR | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: us-central1-docker.pkg.dev | |
| username: _json_key | |
| password: ${{ secrets.ORPHAN_DOMAIN_HANDLER_KOPS_DEV_STG_DEPLOYMENT_KEY }} | |
| - name: Build and Push Docker Image to GAR | |
| uses: docker/build-push-action@v2 | |
| with: | |
| push: true | |
| context: ./orphan-domain-handler | |
| file: ./DockerfileODH | |
| tags: | |
| us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.NAMESPACE }}/${{ env.SERVICE_NAME }}:${{ github.sha }} | |
| - id: output-image | |
| run: | |
| echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.NAMESPACE }}/${{ env.SERVICE_NAME }}:${{ github.sha }}`" >> "$GITHUB_OUTPUT" | |
| deployment: | |
| runs-on: ubuntu-latest | |
| needs: dockerize | |
| name: 🚀 Deploy | |
| env: | |
| image: ${{ needs.dockerize.outputs.image }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v2 | |
| - name: Authorize to GCP service account | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.ORPHAN_DOMAIN_HANDLER_KOPS_DEV_STG_DEPLOYMENT_KEY }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Update Kubectl component | |
| run: gcloud --quiet components update kubectl | |
| - name: Set GCloud Project and Fetch Cluster Credentials | |
| run: | |
| gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }} | |
| - name: Update Deployment Image | |
| run: | |
| kubectl set image deployment/${{ env.SERVICE_NAME }} ${{ env.SERVICE_NAME }}=${{ env.image }} --namespace ${{ env.NAMESPACE }} |