3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-07-07 05:57:28 +02:00
pbot/.github/workflows/candide.yaml
2024-03-08 23:07:40 -05:00

72 lines
1.6 KiB
YAML

name: candide
on:
push:
branches:
- master
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: pragma
GKE_ZONE: us-central1-c
DEPLOYMENT_NAME: candide
NAMESPACE: candide
REPOSITORY: pbot
IMAGE: pbot
jobs:
build:
name: Build & Deploy
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 'Authenticate to Google Cloud'
id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up GKE credentials
uses: google-github-actions/get-gke-credentials@v2
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
- name: Testing
run: |
kubectl get pods
- name: Authenticate Docker
run: |
gcloud auth configure-docker
- name: Build image
run: |-
docker build --tag "gcr.io/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA" .
- name: Push image
run: |-
docker push "gcr.io/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA"
- uses: jitterbit/get-changed-files@v1
id: changed_files
- name: List changed files
run: |
for changed_file in ${{ steps.changed_files.outputs.all }}; do
echo "Modified: ${changed_file}"
done
- name: Deploy
run: |-
sed -i -e "s/PROJECT_ID/$PROJECT_ID/g" -e "s/REPOSITORY/$REPOSITORY/g" -e "s/IMAGE/$IMAGE/g" -e "s/GITHUB_SHA/$GITHUB_SHA/g" k8s/deployment.yaml
kubectl apply -f k8s/deployment.yaml