1
0
Fork 0
datetime.link/.github/workflows/deploy.yml

81 lines
2.0 KiB
YAML

name: Deploy
on:
push:
tags: ["v*"]
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Login
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker tags
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
id: meta
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
pull: true
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy to pricklypear
runs-on: ubuntu-latest
needs: publish
environment:
name: production
url: https://datetime.link
steps:
- name: Import SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "pricklypear.cacti.makerforce.io ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGd9tL56+YUDQjyGy3iZNGUtjVkvAD442Q6Kt53Zsy8g" >> ~/.ssh/known_hosts
- name: Re-pull
run: |
ssh datetime@pricklypear.cacti.makerforce.io "podman login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io && podman pull ghcr.io/serverwentdown/datetime.link:main"
- name: Restart
run: |
ssh datetime@pricklypear.cacti.makerforce.io "systemctl restart --user container-datetime.service"
# vim: set et ts=2 sw=2: