forked from colorstackorg/podspace-server-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (43 loc) · 1.78 KB
/
deploy.yml
File metadata and controls
49 lines (43 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Docker Build & Push and Deploy to podspace-server
on:
push:
branches:
- main
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PAT }}
- name: Read Docker Image Identifiers
id: read-docker-image-identifiers
run: |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo IMAGE_TAG=$(git rev-parse --short HEAD) >> $GITHUB_ENV
- name: Docker Build & Push
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest
- name: Remote SSH and Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: deployer
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
echo ${{ secrets.ENV_PRODUCTION }} | base64 --decode > .env.production-${{ secrets.POD_NUMBER }}
docker login https://ghcr.io -u ${{ github.repository_owner }} -p ${{ secrets.DOCKER_PAT }}
docker pull ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest
docker container rm -f podspace-${{ secrets.POD_NUMBER }} || true
docker run --env-file .env.production-${{ secrets.POD_NUMBER }} -d -p ${{ secrets.SERVER_PORT }}:8080 --restart on-failure --name=podspace-${{ secrets.POD_NUMBER }} ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest
rm .env.production-${{ secrets.POD_NUMBER }}