Merge pull request #12 from netCard-TUK/hm #6
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
name: Node.js Package | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: login docker | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/netcard:latest . | |
docker push ${{ secrets.DOCKER_USERNAME }}/netcard:latest | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ubuntu | |
key: ${{ secrets.EC2_KEY }} | |
script: | | |
rm .env | |
echo "${{ secrets.ENV }}" > .env | |
sudo docker stop netcard || true | |
sudo docker rm netcard || true | |
sudo docker rmi ${{ secrets.DOCKER_USERNAME }}/netcard:latest || true | |
sudo docker-compose up -d |