-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (73 loc) · 2.79 KB
/
release.yml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Release
on:
release:
types: [published]
jobs:
push_to_registry:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: repository name fix
run: echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push Docker images
uses: docker/[email protected]
with:
file: Dockerfile
context: .
push: true
tags: ghcr.io/${{ env.image_repository_name }}:${{ github.event.release.tag_name }}
deploy_via_ssh:
needs: push_to_registry
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: repository name fix and env
run: |
echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
echo "domain=${{ secrets.DEPLOY_HOST }}" >> $GITHUB_ENV
echo "letsencrypt_email=${{ secrets.LETSENCRYPT_EMAIL }}" >> $GITHUB_ENV
- name: docker-compose file prep
uses: danielr1996/[email protected]
env:
RELEASE_VERSION: ${{ github.event.release.tag_name }}
IMAGE_REPO: ${{ env.image_repository_name }}
HOST_DOMAIN: ${{ env.domain }}
LETSENCRYPT_EMAIL: ${{ env.letsencrypt_email }}
with:
input: deploy/docker-compose-template.yml
output: deploy/VuetifyNuxt-docker-compose.yml
- name: copy compose file via scp
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
port: ${{ secrets.DEPLOY_PORT }}
key: ${{ secrets.DEPLOY_KEY }}
source: "deploy/VuetifyNuxt-docker-compose.yml"
target: "~/"
- name: Set the value
run: |
echo "GH_TOKEN=${{ secrets.CR_PAT }}" >> $GITHUB_ENV
echo "USERNAME=${{ secrets.DEPLOY_USERNAME }}" >> $GITHUB_ENV
- name: remote docker-compose up via ssh
uses: appleboy/[email protected]
env:
APPTOKEN: ${{ env.GH_TOKEN }}
USERNAME: ${{ env.USERNAME }}
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
port: ${{ secrets.DEPLOY_PORT }}
envs: APPTOKEN,USERNAME
script: |
echo $APPTOKEN | docker login ghcr.io -u $USERNAME --password-stdin
docker-compose -f ~/deploy/VuetifyNuxt-docker-compose.yml up -d