Skip to content

Commit

Permalink
private registry
Browse files Browse the repository at this point in the history
  • Loading branch information
eufelipemateus committed May 2, 2024
1 parent df6df43 commit 1c7cdf0
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/deploy_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,32 @@ jobs:
set-safe-directory: false

- name: Login Docker
run: docker login -u "eufelipemateus" -p "${{secrets.DOCKER_TOKEN}}"
run: docker login -u "adminuser" -p "${{secrets.DOCKER_TOKEN}}" docker.felipemateus.com

- name: Build
run: docker build -t ${{ github.repository_owner }}/${{ github.event.repository.name }}:test -f ./docker/Dockerfile . # tag ${{ github.head_ref || github.ref_name }}

- name: Sync Tag
run: docker tag ${{ github.repository_owner }}/${{ github.event.repository.name }}:test docker.felipemateus.com/${{ github.event.repository.name }} # tag ${{ github.head_ref || github.ref_name }}

- name: Push docker
run: docker push ${{ github.repository_owner }}/${{ github.event.repository.name }}:test # tag ${{ github.head_ref || github.ref_name }}
run: docker push docker.felipemateus.com/${{ github.event.repository.name }} # tag ${{ github.head_ref || github.ref_name }}

- name: Write SSH keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{secrets.SSH_HOST}} > ~/.ssh/known_hosts
- name: Deploy with rsync
run: rsync -rav --delete ./ ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}}:${{secrets.WORK_DIR}}
- name: Restart Apps
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd ${{secrets.WORK_DIR}}
docker login -u "adminuser" -p "${{secrets.DOCKER_TOKEN}}" docker.felipemateus.com
docker rm $(docker stop $(docker ps -a -q --filter ancestor=${{ github.event.repository.name }} --format="{{.ID}}")) -f
docker run --restart=always --network=host -dp 127.0.0.1:8000:8000 --name ${{ github.event.repository.name }} ${{ github.repository_owner }}/${{ github.event.repository.name }}:test

0 comments on commit 1c7cdf0

Please sign in to comment.