Merge pull request #100 from chipp/reconnect-issues #130
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish and deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
push: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
strategy: | |
matrix: | |
include: | |
- binary: alisa | |
arch: linux/arm64 | |
- binary: elisa | |
arch: linux/amd64 | |
- binary: elizabeth | |
arch: linux/arm64 | |
- binary: isabel | |
arch: linux/amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log into registry | |
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@master | |
- name: Build and push image | |
run: | | |
IMAGE_ID=ghcr.io/chipp/${{ matrix.binary }} | |
docker buildx build . --file bin/${{ matrix.binary }}/Dockerfile \ | |
--push \ | |
--platform ${{ matrix.arch }} \ | |
--tag $IMAGE_ID:latest \ | |
--build-arg VERSION="0.1.${{ github.run_number }}" \ | |
--label "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ | |
--cache-from=type=registry,ref=$IMAGE_ID:cache \ | |
--cache-to=type=registry,ref=$IMAGE_ID:cache,mode=max | |
deploy: | |
runs-on: ubuntu-latest | |
needs: push | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log into registry | |
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin | |
- name: Add ssh key | |
run: | | |
mkdir ~/.ssh/ | |
echo "${{ secrets.ssh_key }}" > ~/.ssh/id_rsa | |
echo "ezio.chipp.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHynflleQHqQg0GHDph+GkNQARa56hAlJJf4ogGKbwsh" >> ~/.ssh/known_hosts | |
echo "pi3.chipp.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID4miYPJr5cirlqtd73clGvCXI/kiqe23UkfXTtgDyuM" >> ~/.ssh/known_hosts | |
echo "Host pi3.chipp.dev" > ~/.ssh/config | |
echo " ProxyCommand $PWD/cloudflared-linux-amd64 access ssh --hostname %h" >> ~/.ssh/config | |
chmod -R 700 ~/.ssh/ | |
- name: Install cloudflared | |
run: | | |
curl -sSLO https://github.com/cloudflare/cloudflared/releases/download/2023.10.0/cloudflared-linux-amd64 | |
echo "33e6876bd55c2db13a931cf812feb9cb17c071ab45d3b50c588642b022693cdc cloudflared-linux-amd64" | sha256sum -c - | |
chmod +x cloudflared-linux-amd64 | |
- name: Deploy alisa and elizabeth | |
run: | | |
eval `ssh-agent -s` | |
echo "${{ secrets.ssh_key_passphrase }}" | ssh-add ~/.ssh/id_rsa | |
scp conf/docker-compose.yml conf/mq.conf \ | |
[email protected]:/web/lisa | |
ssh [email protected] \ | |
"cd /web/lisa && docker compose down --remove-orphans --rmi all && docker compose up -d" | |
- name: Extract elisa | |
run: | | |
docker run --rm -v "$PWD/build:/build" ghcr.io/chipp/elisa:latest cp /root/elisa /build/elisa | |
- name: Extract isabel | |
run: | | |
docker run --rm -v "$PWD/build:/build" ghcr.io/chipp/isabel:latest cp /root/isabel /build/isabel | |
- name: Deploy elisa and isabel | |
run: | | |
eval `ssh-agent -s` | |
echo "${{ secrets.ssh_key_passphrase }}" | ssh-add ~/.ssh/id_rsa | |
export TUNNEL_SERVICE_TOKEN_ID=${{ secrets.TUNNEL_SERVICE_TOKEN_ID }} | |
export TUNNEL_SERVICE_TOKEN_SECRET=${{ secrets.TUNNEL_SERVICE_TOKEN_SECRET }} | |
ssh -v [email protected] "echo test" | |
ssh [email protected] "sudo service elisa stop && sudo service isabel stop" | |
scp build/elisa build/isabel [email protected]:/usr/local/bin | |
ssh [email protected] "sudo service elisa start && sudo service isabel start" |