-
Notifications
You must be signed in to change notification settings - Fork 2
57 lines (50 loc) · 1.48 KB
/
cicd.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
name: Rust
on:
push:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
concurrency:
group: "cicd"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Get Build Time
run: echo "TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
push: true
tags: |
ghcr.io/ezrizhu/www:${{ github.sha }}
ghcr.io/ezrizhu/www:latest
build-args: |
COMMIT=${{ github.sha }}
REF=${{ github.ref }}
TIME=${{ env.TIME }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Trigger www0 to update
run: ${{ secrets.WTWWW0 }}
- name: Deployment Grace Period
run: sleep 5
- name: Ensure that www0 is updated
run: 'curl -H "X-Server-Select: www0" https://ezrizhu.com | grep ${{ github.sha }}'
- name: Trigger www1 to update
run: ${{ secrets.WTWWW1 }}
- name: Deployment Grace Period
run: sleep 5
- name: Ensure that www1 is updated
run: 'curl -H "X-Server-Select: www1" https://ezrizhu.com | grep ${{ github.sha }}'
- name: Ensure that default is updated
run: 'curl https://ezrizhu.com | grep ${{ github.sha }}'