-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (80 loc) · 2.43 KB
/
build.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: Build, Publish, and Deploy
on:
push:
branches:
- main
jobs:
# publish:
# name: Build and Publish
# runs-on: ubuntu-latest
# env:
# IMAGE_NAME: mopad
# IMAGE_TAGS: latest ${{ github.sha }} ${{ github.ref_name }}
# IMAGE_REGISTRY: docker://ghcr.io/hulks/
# REGISTRY_USER: ${{ github.actor }}
# REGISTRY_PASSWORD: ${{ github.token }}
# steps:
# - uses: actions/checkout@v4
# with:
# lfs: true
#
# - name: build image
# id: build-image
# uses: redhat-actions/buildah-build@v2
# with:
# image: ${{ env.IMAGE_NAME }}
# tags: ${{ env.IMAGE_TAGS }}
# containerfiles: |
# ./Containerfile
#
# - name: push to ghcr.io
# id: push-to-registry
# uses: redhat-actions/push-to-registry@v2
# with:
# image: ${{ steps.build-image.outputs.image }}
# tags: ${{ steps.build-image.outputs.tags }}
# registry: ${{ env.IMAGE_REGISTRY }}
# username: ${{ env.REGISTRY_USER }}
# password: ${{ env.REGISTRY_PASSWORD }}
#
# - name: echo outputs
# run: |
# echo "${{ toJSON(steps.push-to-registry.outputs) }}"
#
deploy:
needs: publish
name: Deploy
runs-on: self-hosted
container:
image: docker.io/debian:bookworm
steps:
- name: setup ssh
run : |
set -e
apt update
apt install --yes ssh
- name: install ssh keys
# run: |
# install -m 600 -D /dev/null ~/.ssh/id_ed25519
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
# ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
# - name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/staging.key
chmod 600 ~/.ssh/staging.key
cat > ~/.ssh/config <<END
Host staging
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/staging.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
- name: connect and pull
run: ssh -v staging "cd ${{ secrets.WORK_DIR }} && docker compose pull && docker compose up -d && exit"
- name: cleanup
run: rm -rf ~/.ssh