-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: Deploy | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Docker Hub Login | ||
run: | | ||
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ vars.DOCKER_HUB_USER }} --password-stdin docker.io | ||
- name: Build Docker Image | ||
run: | | ||
docker build -t ${{ vars.DOCKER_HUB_USER }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ vars.DOCKER_IMAGE_TAG }} . | ||
- name: Push Image to Docker Hub | ||
run: docker push ${{ vars.DOCKER_HUB_USER }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ vars.DOCKER_IMAGE_TAG }} | ||
|
||
- name: Run Docker Image | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.DEPLOYMENT_HOST }} | ||
username: ${{ secrets.DEPLOYMENT_HOST_USERNAME }} | ||
key: ${{ secrets.DEPLOYMENT_HOST_KEY }} | ||
port: 22 | ||
script: | | ||
docker container rm -f ${{ vars.DOCKER_CONTAINER_NAME }} | ||
docker image rm -f ${{ vars.DOCKER_HUB_USER }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ vars.DOCKER_IMAGE_TAG }} | ||
docker run --name ${{ vars.DOCKER_CONTAINER_NAME }} -e USER_MICROSERVICE_URL=${{ secrets.USER_MICROSERVICE_URL }} -e RABBITMQ_CONNECTION_STRING=${{ secrets.RABBITMQ_CONNECTION_STRING }} -d --restart unless-stopped -p 8080:8080 ${{ vars.DOCKER_HUB_USER }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ vars.DOCKER_IMAGE_TAG }} |