-
Notifications
You must be signed in to change notification settings - Fork 44
36 lines (29 loc) · 1.05 KB
/
ci.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
name: CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 1. Set env
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
echo "SHORT_SHA=$(echo ${GITHUB_SHA:0:4})" >> $GITHUB_ENV
echo "DATE=$(TZ=Asia/Shanghai date +%Y-%m-%d.%H-%M-%S)" >> $GITHUB_ENV
- name: 2. Build Docker image
run: |
docker build -t cairry/watchalert:$BRANCH_NAME.$DATE.$SHORT_SHA --build-arg VERSION=$BRANCH_NAME.$DATE.$SHORT_SHA .
docker tag cairry/watchalert:$BRANCH_NAME.$DATE.$SHORT_SHA cairry/watchalert:latest
- name: 3. Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 4. Push Docker image to Docker Hub
run: |
docker push cairry/watchalert:latest
docker push cairry/watchalert:$BRANCH_NAME.$DATE.$SHORT_SHA