Skip to content

Commit

Permalink
cicd: init
Browse files Browse the repository at this point in the history
  • Loading branch information
Emyr298 committed Jun 27, 2024
1 parent 0cf41c9 commit 1ae03f1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/deployment.yml
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 }}

0 comments on commit 1ae03f1

Please sign in to comment.