Skip to content

Commit

Permalink
ci: use docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryDorofeev committed Nov 20, 2024
1 parent c8319c4 commit d16265c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 71 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Docker Build

# 202411201117
# 1.1.1
# abcde789

on:
push:
branches: [master]
Expand All @@ -8,7 +12,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Build Docker image
Expand All @@ -18,25 +22,25 @@ jobs:
docker push dmitrydorofeev/godeploy:${GITHUB_SHA::8}
docker push dmitrydorofeev/godeploy:latest
# deploy:
# runs-on: ubuntu-latest
# needs: build
# steps:
# - name: pull docker image
# uses: appleboy/ssh-action@master
# with:
# envs: GITHUB_SHA
# host: 37.139.41.28
# username: ubuntu
# key: ${{ secrets.PRIVATE_KEY }}
# script: sudo docker pull dmitrydorofeev/godeploy:${GITHUB_SHA::8}
# - name: deploy docker image
# uses: appleboy/ssh-action@master
# with:
# envs: GITHUB_SHA
# host: 37.139.41.28
# username: ubuntu
# key: ${{ secrets.PRIVATE_KEY }}
# script: |
# sudo docker rm -f $(sudo docker ps -aq)
# sudo docker run -e VERSION=${GITHUB_SHA::8} -d -p 8080:8080 dmitrydorofeev/godeploy:${GITHUB_SHA::8}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: pull docker image
uses: appleboy/ssh-action@master
with:
envs: GITHUB_SHA
host: 217.16.27.70
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: sudo docker pull dmitrydorofeev/godeploy:${GITHUB_SHA::8}
- name: deploy docker image
uses: appleboy/ssh-action@master
with:
envs: GITHUB_SHA
host: 217.16.27.70
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker rm -f $(sudo docker ps -aq)
sudo docker run -e VERSION=${GITHUB_SHA::8} -d -p 8080:8080 dmitrydorofeev/godeploy:${GITHUB_SHA::8}
86 changes: 43 additions & 43 deletions .github/workflows/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,46 @@ jobs:
name: bin
path: ./bin/app

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download bin file
uses: actions/download-artifact@v4
with:
name: bin
path: ./bin
- name: Transfer bin file to server
uses: appleboy/scp-action@master
with:
host: 217.16.27.70
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
debug: true
source: "bin/app"
target: "/home/ubuntu"
- name: Transfer migrations files to server
uses: appleboy/scp-action@master
with:
host: 217.16.27.70
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
debug: true
source: "migrations"
target: "/home/ubuntu/bin"
- name: chmod
uses: appleboy/ssh-action@master
with:
host: 217.16.27.70
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: chmod 755 /home/ubuntu/bin/app
- name: restart service
uses: appleboy/ssh-action@master
with:
host: 217.16.27.70
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: sudo systemctl restart api.service
# deploy:
# runs-on: ubuntu-latest
# needs: build
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Download bin file
# uses: actions/download-artifact@v4
# with:
# name: bin
# path: ./bin
# - name: Transfer bin file to server
# uses: appleboy/scp-action@master
# with:
# host: 217.16.27.70
# username: ubuntu
# key: ${{ secrets.PRIVATE_KEY }}
# debug: true
# source: "bin/app"
# target: "/home/ubuntu"
# - name: Transfer migrations files to server
# uses: appleboy/scp-action@master
# with:
# host: 217.16.27.70
# username: ubuntu
# key: ${{ secrets.PRIVATE_KEY }}
# debug: true
# source: "migrations"
# target: "/home/ubuntu/bin"
# - name: chmod
# uses: appleboy/ssh-action@master
# with:
# host: 217.16.27.70
# username: ubuntu
# key: ${{ secrets.PRIVATE_KEY }}
# script: chmod 755 /home/ubuntu/bin/app
# - name: restart service
# uses: appleboy/ssh-action@master
# with:
# host: 217.16.27.70
# username: ubuntu
# key: ${{ secrets.PRIVATE_KEY }}
# script: sudo systemctl restart api.service
10 changes: 5 additions & 5 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
dest: /etc/systemd/system/api.service
- name: "Systemctl daemon reload"
command: systemctl daemon-reload
# - name: "Install docker"
# become: yes
# hosts: all
# roles:
# - role: geerlingguy.docker
- name: "Install docker"
become: yes
hosts: all
roles:
- role: geerlingguy.docker
# - name: "Install nginx"
# become: yes
# hosts: web
Expand Down

0 comments on commit d16265c

Please sign in to comment.