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

81 lines
2.0 KiB
YAML
Raw Permalink Normal View History

2020-11-08 00:57:43 +08:00
name: Deploy
on:
push:
2021-11-16 12:21:31 +08:00
tags: ["v*"]
2020-11-08 00:57:43 +08:00
branches: [ main ]
2021-11-16 12:21:31 +08:00
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
2020-11-08 00:57:43 +08:00
jobs:
2020-11-08 02:19:51 +08:00
publish:
name: Publish
2020-11-08 00:57:43 +08:00
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
2021-11-16 12:21:31 +08:00
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
2020-11-08 00:57:43 +08:00
with:
2021-11-16 12:21:31 +08:00
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
2021-11-16 21:47:33 +08:00
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
2021-11-16 12:21:31 +08:00
id: meta
2020-11-08 00:57:43 +08:00
- name: Build and push Docker images
2021-11-16 12:21:31 +08:00
uses: docker/build-push-action@v2
2020-11-08 00:57:43 +08:00
with:
pull: true
2020-11-08 14:49:23 +08:00
platforms: linux/amd64
2020-11-08 00:57:43 +08:00
push: true
2021-11-16 12:21:31 +08:00
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2020-11-08 00:57:43 +08:00
2020-11-08 02:19:51 +08:00
deploy:
name: Deploy to pricklypear
runs-on: ubuntu-latest
needs: publish
2021-11-16 13:05:25 +08:00
environment:
name: production
url: https://datetime.link
2020-11-08 02:19:51 +08:00
steps:
2020-11-08 00:57:43 +08:00
- name: Import SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
2021-11-16 12:31:13 +08:00
echo "pricklypear.cacti.makerforce.io ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGd9tL56+YUDQjyGy3iZNGUtjVkvAD442Q6Kt53Zsy8g" >> ~/.ssh/known_hosts
2020-11-08 00:57:43 +08:00
- name: Re-pull
run: |
2021-11-16 12:31:13 +08:00
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"
2020-11-08 00:57:43 +08:00
- name: Restart
run: |
2021-11-16 12:31:13 +08:00
ssh datetime@pricklypear.cacti.makerforce.io "systemctl restart --user container-datetime.service"
2020-11-08 00:57:43 +08:00
# vim: set et ts=2 sw=2: