Merge pull request #3 from ginruh/dev #2
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: Create and publish images | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
attestations: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push listener image | |
id: push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: src/listener/Dockerfile | |
push: true | |
tags: ghcr.io/${{ github.repository }}/listener:latest | |
- name: Setup ssh key | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.ACTION_PRIVATE_KEY }}" > ~/.ssh/github_action.key | |
sudo chmod 600 ~/.ssh/github_action.key | |
ssh-keyscan -H ${{ secrets.SERVER_IP }} > ~/.ssh/known_hosts | |
- name: Deploy | |
run: | | |
ssh {{ secrets.SERVER_USERNAME }}@{{ secrets.SERVER_IP }} /bin/bash << EOF | |
cd {{ secrets.REPO_PATH }}; | |
git pull origin master; | |
docker compose down; | |
docker compose pull; | |
docker compose up -d; | |
EOF |