Inicia Implementacao de Refresh

This commit is contained in:
2024-10-16 23:19:04 -03:00
parent f7844975e5
commit 7075e86a26
4 changed files with 47 additions and 115 deletions

30
.github/workflows/deploy-cluster.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: remote ssh command
on:
repository_dispatch:
types: [deploy-prod]
push:
branches:
- main
- staging
jobs:
build:
name: Deploy to Cluster
environment: ${{ github.ref_name == 'main' && 'prod' || 'staging' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Writing Env File
run: |
echo "${{ secrets.ENV_FILE }}" | base64 -d > .env
- name: Set Kubernetes Context
uses: azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- name: Execute deploy
run: |
./deploy.sh -f .env

View File

@@ -1,58 +0,0 @@
name: remote ssh command
on:
repository_dispatch:
types: [deploy-prod]
push:
branches:
- main
jobs:
build:
name: Build
environment: prod
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Create Config Json File
run: |
echo "${{ secrets.CONFIG_JSON }}" | base64 -d > config.json
- name: Inserts Prod Enviromental Variables
run: |
python -m pip install --upgrade pip pipenv
pipenv install
pipenv run python setup.py -e prod -f config.json
- name: copy file via ssh
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
source: "."
target: "infra-hideyoshi.com"
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
command_timeout: 30m
script: |
sudo apt update && sudo apt install -y jq
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
source ~/.profile
cd infra-hideyoshi.com
./deploy.sh --prod
./refresh.sh

View File

@@ -1,56 +0,0 @@
name: remote ssh command
on:
push:
branches:
- staging
jobs:
build:
name: Build
environment: staging
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Create Config Json File
run: |
echo "${{ secrets.CONFIG_JSON }}" | base64 -d > config.json
- name: Inserts Prod Enviromental Variables
run: |
python -m pip install --upgrade pip pipenv
pipenv install
pipenv run python setup.py -e staging -f config.json
- name: copy file via ssh
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
source: "."
target: "infra-hideyoshi.com"
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
command_timeout: 30m
script: |
sudo apt update && sudo apt install -y jq
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
source ~/.profile
cd infra-hideyoshi.com
./deploy.sh --staging
./refresh.sh

View File

@@ -149,8 +149,13 @@ main() {
} }
refresh() {
}
environment="remote" environment="remote"
setup_minikube="false" setup_minikube="false"
execution_mode="deploy"
while getopts ":f:e:mh" opt; do while getopts ":f:e:mh" opt; do
case ${opt} in case ${opt} in
@@ -170,6 +175,10 @@ while getopts ":f:e:mh" opt; do
echo "Usage: deploy.sh [-f <env_file>] [-e <environment>] [-m <minikube>]" echo "Usage: deploy.sh [-f <env_file>] [-e <environment>] [-m <minikube>]"
exit 0 exit 0
;; ;;
r )
echo "Executing Refresh"
execution_mode="refresh"
;;
*) *)
echo "Invalid option: $OPTARG" echo "Invalid option: $OPTARG"
exit 1 exit 1
@@ -177,4 +186,11 @@ while getopts ":f:e:mh" opt; do
esac esac
done done
main if [[ $execution_mode == "deploy" ]]; then
main
elif [[ $execution_mode == "refresh" ]]; then
refresh
else
echo "Invalid execution mode: $execution_mode"
exit 1
fi