mirror of
https://github.com/pragma-/pbot.git
synced 2025-07-07 14:07:28 +02:00
123 lines
3.3 KiB
YAML
123 lines
3.3 KiB
YAML
name: candide on Libera
|
|
|
|
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: pbot
|
|
IMAGE_VM: pbot-vm
|
|
|
|
jobs:
|
|
pbot:
|
|
name: PBot
|
|
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: Authenticate Docker
|
|
run: |
|
|
gcloud auth configure-docker
|
|
|
|
- name: Build image
|
|
run: |-
|
|
docker build --tag "gcr.io/$PROJECT_ID/$REPOSITORY/$IMAGE_PBOT:$GITHUB_SHA" .
|
|
|
|
- name: Push image
|
|
run: |-
|
|
docker push "gcr.io/$PROJECT_ID/$REPOSITORY/$IMAGE_PBOT:$GITHUB_SHA"
|
|
|
|
- name: Get all changed non-plugin files
|
|
id: changed-non-plugin-files
|
|
uses: tj-actions/changed-files@v42
|
|
with:
|
|
files_ignore: |
|
|
lib/PBot/Plugin/**.pm
|
|
|
|
- name: Get all changed plugin files
|
|
id: changed-plugin-files
|
|
uses: tj-actions/changed-files@v42
|
|
with:
|
|
files: |
|
|
lib/PBot/Plugin/**.pm
|
|
|
|
- name: Hot-reload plugin files
|
|
if: steps.changed-plugin-files.outputs.any_changed == 'true' && steps.changed-non-plugin-files.outputs.any_changed == 'false'
|
|
env:
|
|
ALL_CHANGED_FILES: ${{ steps.changed-plugin-files.outputs.all_changed_files }}
|
|
run: |
|
|
for file in ${ALL_CHANGED_FILES}; do
|
|
echo "$file was changed"
|
|
done
|
|
|
|
- name: Deploy with restart
|
|
if: steps.changed-non-plugin-files.outputs.any_changed == 'true'
|
|
run: |-
|
|
sed -i -e "s/PROJECT_ID/$PROJECT_ID/g" -e "s/REPOSITORY/$REPOSITORY/g" -e "s/IMAGE/$IMAGE_PBOT/g" -e "s/GITHUB_SHA/$GITHUB_SHA/g" k8s/deployment.yaml
|
|
kubectl apply -f k8s/candide-pbot.yaml
|
|
|
|
vms:
|
|
name: VMs
|
|
runs-on: ubuntu-latest
|
|
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: Authenticate Docker
|
|
run: |
|
|
gcloud auth configure-docker
|
|
|
|
- name: Build image
|
|
run: |-
|
|
docker build --tag "gcr.io/$PROJECT_ID/$REPOSITORY/$IMAGE_VM:$GITHUB_SHA" -f applets/pbot-vm/Dockerfile .
|
|
|
|
- name: Push image
|
|
run: |-
|
|
docker push "gcr.io/$PROJECT_ID/$REPOSITORY/$IMAGE_VM:$GITHUB_SHA"
|
|
|
|
- name: Deploy
|
|
run: |-
|
|
sed -i -e "s/PROJECT_ID/$PROJECT_ID/g" -e "s/REPOSITORY/$REPOSITORY/g" -e "s/IMAGE/$IMAGE_VM/g" -e "s/GITHUB_SHA/$GITHUB_SHA/g" k8s/deployment.yaml
|
|
kubectl apply -f k8s/candide-vm.yaml
|