hack
This commit is contained in:
59
.gitea/actions/deploy/action.yaml
Normal file
59
.gitea/actions/deploy/action.yaml
Normal file
@@ -0,0 +1,59 @@
|
||||
name: 'deploy'
|
||||
description: 'deploy'
|
||||
|
||||
inputs:
|
||||
environment:
|
||||
required: true
|
||||
type: string
|
||||
tag:
|
||||
required: true
|
||||
type: string
|
||||
migrate:
|
||||
type: bool
|
||||
default: false
|
||||
secrets:
|
||||
required: false
|
||||
type: string
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Yandex Cloud Login
|
||||
uses: yc-actions/yc-cr-login@v2
|
||||
with:
|
||||
yc-sa-json-credentials: ${{ fromJSON(inputs.secrets).YC_SA_JSON_CREDENTIALS }}
|
||||
- name: Import Secrets
|
||||
uses: hashicorp/vault-action@v2
|
||||
id: vault
|
||||
with:
|
||||
url: https://vault.hublab.ru/
|
||||
method: approle
|
||||
roleId: ${{ fromJSON(inputs.secrets).VAULT_ROLE_ID }}
|
||||
secretId: ${{ fromJSON(inputs.secrets).VAULT_SECRET_ID }}
|
||||
secrets: |
|
||||
hub/data/tach/${{ inputs.environment }}/base *;
|
||||
hub/data/tach/${{ inputs.environment }}/${{github.event.repository.name}} *;
|
||||
- name: Save envs
|
||||
run: |
|
||||
echo '${{ toJson(steps.vault.outputs) }}' > output.json
|
||||
jq -r 'to_entries[] | "\(.key)=\"\(.value)\""' output.json > .env
|
||||
source .env
|
||||
cat .env
|
||||
- name: Pull
|
||||
env:
|
||||
DOCKER_HOST: tcp://${{ inputs.host }}:2376
|
||||
run: |
|
||||
docker compose pull
|
||||
- name: Migrate
|
||||
if: ${{ inputs.migrate == 'true' }}
|
||||
env:
|
||||
DOCKER_HOST: tcp://${{ inputs.host }}:2376
|
||||
run: |
|
||||
docker compose run --rm ${CR_REPO:8} alembic upgrade head
|
||||
- name: Deploy
|
||||
env:
|
||||
DOCKER_HOST: tcp://${{ inputs.host }}:2376
|
||||
run: |
|
||||
docker compose -p ${{ inputs.environment }} up -d --force-recreate
|
||||
50
.github/workflows/deploy.yaml
vendored
50
.github/workflows/deploy.yaml
vendored
@@ -30,48 +30,10 @@ jobs:
|
||||
CR_REPO: ${{ github.event.repository.name }}
|
||||
TAG: ${{ inputs.tag }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Yandex Cloud Login
|
||||
uses: yc-actions/yc-cr-login@v2
|
||||
- name: deploy
|
||||
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/deploy@HEAD
|
||||
with:
|
||||
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
|
||||
- name: Import Secrets
|
||||
uses: hashicorp/vault-action@v2
|
||||
id: vault
|
||||
with:
|
||||
url: https://vault.hublab.ru/
|
||||
method: approle
|
||||
roleId: ${{ secrets.VAULT_ROLE_ID }}
|
||||
secretId: ${{ secrets.VAULT_SECRET_ID }}
|
||||
secrets: |
|
||||
hub/data/tach/${{ inputs.environment }}/base *;
|
||||
hub/data/tach/${{ inputs.environment }}/${{github.event.repository.name}} *;
|
||||
- name: Save envs
|
||||
run: |
|
||||
echo '${{ toJson(steps.vault.outputs) }}' > output.json
|
||||
jq -r 'to_entries[] | "\(.key)=\"\(.value)\""' output.json > .env
|
||||
source .env
|
||||
cat .env
|
||||
- name: Pull
|
||||
env:
|
||||
DOCKER_HOST: tcp://${{ inputs.host }}:2376
|
||||
run: |
|
||||
docker compose pull
|
||||
- name: Migrate
|
||||
if: ${{ inputs.migrate == 'true' }}
|
||||
env:
|
||||
DOCKER_HOST: tcp://${{ inputs.host }}:2376
|
||||
run: |
|
||||
docker compose run --rm ${CR_REPO:8} alembic upgrade head
|
||||
- name: Build
|
||||
if: ${{ inputs.build == 'true' }}
|
||||
env:
|
||||
DOCKER_HOST: tcp://${{ inputs.host }}:2376
|
||||
run: |
|
||||
docker compose build
|
||||
- name: Deploy
|
||||
env:
|
||||
DOCKER_HOST: tcp://${{ inputs.host }}:2376
|
||||
run: |
|
||||
docker compose -p ${{ inputs.environment }} up -d --force-recreate
|
||||
secrets: ${{ toJSON(secrets) }}
|
||||
environment: ${{ inputs.environment }}
|
||||
tag: ${{ inputs.tag }}
|
||||
migrate: ${{ inputs.migrate }}
|
||||
Reference in New Issue
Block a user