-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (57 loc) · 1.96 KB
/
ci.yaml
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
name: '🧑🏭'
on: [ push ]
jobs:
ci:
permissions:
id-token: write
deployments: write
runs-on: ubuntu-latest
steps:
- name: 'Fetch latest commit'
uses: actions/checkout@v3.5.3
- name: 'Install Nix'
uses: cachix/install-nix-action@v22
with:
nix_path: "nixpkgs=channel:nixos-23.05"
- name: 'Activate Nix store cache'
uses: actions/cache@v3.3.1
id: nix-cache
with:
path: "/tmp/nixcache"
key: "nix-store-${{ hashFiles(format('{0}/Makefile', github.workspace)) }}"
- name: "Import Nix store cache"
if: "steps.nix-cache.outputs.cache-hit == 'true'"
run: |
nix-store --import < /tmp/nixcache
- name: 'Build website'
run: |
make
- name: "Export Nix store cache"
if: >
( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' )
&& steps.nix-cache.outputs.cache-hit != 'true'
run: |
nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache
- name: 'Docker Hub login'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 'Publish to Docker Hub'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/website:latest
- name: 'Trigger deployment'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
run: >
curl
--fail
--head
--no-progress-meter
--header "Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}"
"${{ secrets.WATCHTOWER_URL }}"