ci: configura deploy automatico para k3s
This commit is contained in:
parent
d02ba47fe8
commit
c844054828
1 changed files with 17 additions and 8 deletions
|
|
@ -30,9 +30,11 @@ jobs:
|
||||||
docker buildx inspect --bootstrap
|
docker buildx inspect --bootstrap
|
||||||
|
|
||||||
- name: Login to Forgejo Registry
|
- name: Login to Forgejo Registry
|
||||||
run: |
|
uses: docker/login-action@v3
|
||||||
# Tentativa manual de login caso a Action falhe no handshake
|
with:
|
||||||
echo "${{ secrets.FORGEJO_TOKEN }}" | docker login pipe.gohorsejobs.com -u bohessefm --password-stdin
|
registry: pipe.gohorsejobs.com
|
||||||
|
username: bohessefm
|
||||||
|
password: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
|
||||||
- name: Build and Push Backend
|
- name: Build and Push Backend
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
|
|
@ -63,16 +65,20 @@ jobs:
|
||||||
deploy-to-k3s:
|
deploy-to-k3s:
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
runs-on: docker-ready
|
runs-on: docker-ready
|
||||||
|
env:
|
||||||
|
DOCKER_API_VERSION: "1.43"
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: sh
|
shell: sh
|
||||||
steps:
|
steps:
|
||||||
- name: Prepare Deploy
|
- name: Prepare Deploy (Git & Kubectl)
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache git curl
|
apk add --no-cache git curl
|
||||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
if ! command -v kubectl >/dev/null; then
|
||||||
chmod +x kubectl
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
mv kubectl /usr/local/bin/
|
chmod +x kubectl
|
||||||
|
mv kubectl /usr/local/bin/
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -85,11 +91,14 @@ jobs:
|
||||||
|
|
||||||
- name: Update Secrets and Apply
|
- name: Update Secrets and Apply
|
||||||
run: |
|
run: |
|
||||||
|
# Criando o segredo com todas as variáveis necessárias (ajuste se faltar alguma)
|
||||||
kubectl -n gohorsejobsdev delete secret backend-secrets --ignore-not-found
|
kubectl -n gohorsejobsdev delete secret backend-secrets --ignore-not-found
|
||||||
kubectl -n gohorsejobsdev create secret generic backend-secrets \
|
kubectl -n gohorsejobsdev create secret generic backend-secrets \
|
||||||
--from-literal=DATABASE_URL="${{ vars.DATABASE_URL }}" \
|
--from-literal=DATABASE_URL="${{ vars.DATABASE_URL }}" \
|
||||||
--from-literal=JWT_SECRET="${{ vars.JWT_SECRET }}" \
|
--from-literal=JWT_SECRET="${{ vars.JWT_SECRET }}" \
|
||||||
--from-literal=MTU="${{ vars.MTU }}"
|
--from-literal=MTU="${{ vars.MTU }}" \
|
||||||
|
--from-literal=AWS_ACCESS_KEY_ID="${{ vars.AWS_ACCESS_KEY_ID }}" \
|
||||||
|
--from-literal=AWS_SECRET_ACCESS_KEY="${{ vars.AWS_SECRET_ACCESS_KEY }}"
|
||||||
|
|
||||||
kubectl apply -f k8s/dev/ -n gohorsejobsdev
|
kubectl apply -f k8s/dev/ -n gohorsejobsdev
|
||||||
kubectl -n gohorsejobsdev rollout restart deployment gohorse-backend-dev
|
kubectl -n gohorsejobsdev rollout restart deployment gohorse-backend-dev
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue