Skip to content

Merge pull request #9 from Harsche/hotfix/0.1.1 #3

Merge pull request #9 from Harsche/hotfix/0.1.1

Merge pull request #9 from Harsche/hotfix/0.1.1 #3

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push the Docker image to GHCR
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
push: true
tags: ghcr.io/harsche/game-collection-api:latest
- name: List built images
run: docker images
deploy:
needs: build
runs-on: ubuntu-latest
environment: oracle-vm
permissions:
contents: read
steps:
- name: Deploy to Oracle VM
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.ORACLE_VM_HOST }}
username: ${{ secrets.ORACLE_VM_USERNAME }}
key: ${{ secrets.ORACLE_VM_SSH_KEY }}
script: |
GH_ACTOR="${{ github.actor }}"
# Log in to GitHub Container Registry
echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u "$GH_ACTOR" --password-stdin
# Pull the latest image
docker pull ghcr.io/harsche/game-collection-api:latest
# Stop and remove the old container if it exists
docker stop game-collection-api || true
docker rm game-collection-api || true
# Run the new container
docker run -d \
--name game-collection-api \
-p 8080:8080 \
-e ASPNETCORE_ENVIRONMENT=Production \
-e "Jwt__Key=${{ secrets.JWT_SECRET_KEY }}" \
-e "DefaultAdminPassword=${{ secrets.DEFAULT_ADMIN_PASSWORD }}" \
ghcr.io/harsche/game-collection-api:latest