ci: To gitea
This commit is contained in:
1 parent
445527f05a
commit
804f84ecad
1 file changed
@@ -0,0 +1,74 @@
|
||||
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/${{ vars.DOCKER_USERNAME }}/myresume'
|
||||
|
||||
- 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/${{ vars.DOCKER_USERNAME }}/myresume/resume:latest
|
||||
git.rustprogersteam.ru/${{ vars.DOCKER_USERNAME }}/myresume/resume:${{ 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:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Ansible
|
||||
run: apt-get update && apt-get install -y ansible
|
||||
- name: Set up SSH key
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
- name: Trust server host key
|
||||
run: |
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
- 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