Skip to content

Merge pull request #12 from vomaksh/dev #12

Merge pull request #12 from vomaksh/dev

Merge pull request #12 from vomaksh/dev #12

Workflow file for this run

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: Create .env file
run: |
echo "POSTGRES_URI=${{ secrets.APP_POSTGRES_URI }}" > .env
- name: Build and push listener image
uses: docker/build-push-action@v5
with:
context: .
file: src/listener/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}/listener:latest
- name: Build and push top_stories image
uses: docker/build-push-action@v5
with:
context: .
file: src/top_stories/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}/top_stories: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 }} -i ~/.ssh/github_action.key /bin/bash << EOF
cd ${{ secrets.REPO_PATH }};
git pull origin master;
docker compose down;
docker compose pull;
docker compose up -d;
EOF