mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 14:43:24 +00:00
chore: cd workflow
This commit is contained in:
50
.github/workflows/CD.yml
vendored
Normal file
50
.github/workflows/CD.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- test_cd
|
||||
|
||||
jobs:
|
||||
push_image_to_docker_hub:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
uses: actions/checkout@v3
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: docker/metadata-action@v5.0.0
|
||||
with:
|
||||
images: sonny93/my-links
|
||||
flavor: latest=true
|
||||
tags: |
|
||||
type=sha,prefix=
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3.0.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5.0.0
|
||||
with:
|
||||
file: ./Dockerfile
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
|
||||
execute_commands_via_ssh:
|
||||
name: Pull latest docker image and start up the application with Docker Compose
|
||||
runs-on: ubuntu-latest
|
||||
needs: push_image_to_docker_hub
|
||||
steps:
|
||||
- name: Executing remote ssh commands
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script: |
|
||||
docker pull docker.io/sonny93/my-links:latest
|
||||
docker compose up -d
|
||||
Reference in New Issue
Block a user