fix: ci fix
This commit is contained in:
1 parent
8437857ec1
commit
b13f2ccddc
1 file changed
+26
-5
@@ -0,0 +1,95 @@
|
||||
name: Build, Test and Push Flask App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
|
||||
jobs:
|
||||
docker-build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Docker CLI
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y docker.io
|
||||
docker --version
|
||||
|
||||
- name: Configure Docker CLI for insecure registry
|
||||
run: |
|
||||
mkdir -p ~/.docker
|
||||
echo '{"insecure-registries" : ["git.rustprogersteam.ru"]}' > ~/.docker/config.json
|
||||
cat ~/.docker/config.json
|
||||
|
||||
- name: 'Docker Tags'
|
||||
id: tags
|
||||
uses: https://github.com/cssnr/docker-tags-action@v2
|
||||
with:
|
||||
images: 'git.rustprogersteam.ru/pvhproject/pvhfrontend/'
|
||||
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.rustprogersteam.ru
|
||||
username: ${{ vars.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
git.rustprogersteam.ru/pvhproject/pvhfrontend/pvh:latest
|
||||
git.rustprogersteam.ru/pvhproject/pvhfrontend/pvh:${{ github.sha }}
|
||||
labels: ${{ steps.tags.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
deploy:
|
||||
needs: docker-build-and-push
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ansible
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y ansible openssh-client
|
||||
|
||||
- name: Set up SSH key
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s\n' "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keygen -y -f ~/.ssh/deploy_key >/dev/null
|
||||
|
||||
- name: Trust server host key
|
||||
run: |
|
||||
ssh-keyscan -H "${{ secrets.SERVER_IP }}" >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Test SSH
|
||||
run: |
|
||||
ssh \
|
||||
-i ~/.ssh/deploy_key \
|
||||
-o StrictHostKeyChecking=yes \
|
||||
"${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}" \
|
||||
'echo SSH works'
|
||||
|
||||
- name: Run Ansible playbook
|
||||
run: |
|
||||
ansible-playbook \
|
||||
-i "${{ secrets.SERVER_IP }}," \
|
||||
ansible/restart_compose.yml \
|
||||
--user "${{ secrets.SERVER_USER }}" \
|
||||
--private-key ~/.ssh/deploy_key
|
||||
Reference in new issue
Block a user