Merge pull request #47 from HideyoshiNakazone/implements-workflow-dispatcher
Implements workflow dispatcher
This commit is contained in:
1
.github/workflows/deploy-staging.yml
vendored
1
.github/workflows/deploy-staging.yml
vendored
@@ -48,3 +48,4 @@ jobs:
|
||||
sudo apt update && sudo apt install -y jq python3-pip
|
||||
cd infra-hideyoshi.com
|
||||
./deploy.sh --staging
|
||||
./refresh.sh
|
||||
47
.github/workflows/refresh-deployment.yml
vendored
Normal file
47
.github/workflows/refresh-deployment.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: workflow_02
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["build"]
|
||||
branches: [main]
|
||||
types:
|
||||
- completed
|
||||
repository_dispatch:
|
||||
types: [refresh-deployments]
|
||||
|
||||
jobs:
|
||||
refresh-deployments:
|
||||
name: Refresh deployments
|
||||
environment: prod
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Executing Remote Commands - Refresh All Deployments
|
||||
env:
|
||||
deployments: ${{ github.event.client_payload.deployments }}
|
||||
if: ${{ env.deployments == '' || github.event.workflow_run.conclusion == 'success' }}
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USER }}
|
||||
port: ${{ secrets.SSH_PORT }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script: |
|
||||
[[ -d infra-hideyoshi.com ]] && \
|
||||
./infra-hideyoshi.com/refresh.sh
|
||||
|
||||
- name: Executing Remote Commands - Refresh Specific Deployments
|
||||
env:
|
||||
deployments: ${{ github.event.client_payload.deployments }}
|
||||
if: ${{ env.deployments != '' }}
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USER }}
|
||||
port: ${{ secrets.SSH_PORT }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script: |
|
||||
[[ -d infra-hideyoshi.com ]] && \
|
||||
./infra-hideyoshi.com/refresh.sh ${{ env.deployments }}
|
||||
@@ -22,8 +22,8 @@ spec:
|
||||
memory: "256Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "750m"
|
||||
memory: "768Mi"
|
||||
cpu: "500m"
|
||||
ports:
|
||||
- containerPort: 8070
|
||||
env:
|
||||
|
||||
@@ -24,8 +24,8 @@ spec:
|
||||
memory: "256Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "1536Mi"
|
||||
cpu: "750m"
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
env:
|
||||
|
||||
@@ -22,7 +22,7 @@ spec:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
memory: "768Mi"
|
||||
cpu: "500m"
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "1024Mi"
|
||||
cpu: "500m"
|
||||
cpu: "250m"
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
env:
|
||||
|
||||
@@ -22,8 +22,8 @@ spec:
|
||||
memory: "256Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
memory: "256Mi"
|
||||
cpu: "250m"
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
env:
|
||||
|
||||
23
refresh.sh
Executable file
23
refresh.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
NAMESPACES=(
|
||||
portfolio
|
||||
)
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
DEPLOYMENTS=(
|
||||
"frontend-deployment"
|
||||
"backend-deployment"
|
||||
"storage-deployment"
|
||||
"storage-processor-deployment"
|
||||
)
|
||||
else
|
||||
DEPLOYMENTS=("$@")
|
||||
fi
|
||||
|
||||
for i in "${NAMESPACES[@]}"; do
|
||||
for x in "${DEPLOYMENTS[@]}"; do
|
||||
PODS=$(kubectl -n $i get pods --no-headers | awk '{print $1}' | grep $x | tr '\n' ' ')
|
||||
kubectl -n $i delete pods $PODS
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user