-
Notifications
You must be signed in to change notification settings - Fork 63
106 lines (100 loc) · 3.98 KB
/
fava-docker-build.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: "Build fava Docker image"
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'beancount/fava/**'
- '.github/workflows/fava-docker-build.yml'
schedule:
- cron: '30 22 * * 5' # See https://crontab.guru/#0_3_*_*_*
env:
REPOSITORY_NAME: ${{ github.repository }}
GHCR_IMAGE_NAME: ghcr.io/y0ngb1n/dockerized/fava
DOCKERHUB_IMAGE_NAME: y0ngb1n/fava
jobs:
build:
runs-on: ubuntu-latest
if: github.repository == 'y0ngb1n/dockerized'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Fetch fava version
id: get_fava_version
run: |
export TZ='Asia/Shanghai'
echo "build_date=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
local_version=v`sed -nr 's/ARG FAVA_VERSION="(.*)"/\1/p' beancount/fava/Dockerfile`
latest_version=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/beancount/fava/tags | jq -r '.[0].name')
if [ "$local_version" != "$latest_version" ]; then
echo "fava_version=$latest_version" >> $GITHUB_OUTPUT
echo "fava_latest_version=$latest_version" >> $GITHUB_ENV
echo "fava_pip_version=$(echo $fava_version | sed 's/v//g')" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker images
uses: docker/build-push-action@v6
if: steps.get_fava_version.outputs.fava_version != ''
with:
context: fava
file: ./beancount/fava/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm/v7,linux/arm64,linux/amd64,linux/386
build-args: |
FAVA_VERSION=${{ steps.get_fava_version.outputs.fava_pip_version }}
push: true
tags: |
${{ env.GHCR_IMAGE_NAME }}:${{ steps.get_fava_version.outputs.fava_version }}
${{ env.GHCR_IMAGE_NAME }}:latest
${{ env.DOCKERHUB_IMAGE_NAME }}:${{ steps.get_fava_version.outputs.fava_version }}
${{ env.DOCKERHUB_IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update fava version
if: steps.get_fava_version.outputs.fava_version != ''
run: |
sed -i 's/FAVA_VERSION="[^"]*"/FAVA_VERSION="'"$fava_latest_version"'"/g' beancount/fava/Dockerfile
- name: Commit changes
if: steps.get_fava_version.outputs.fava_version != ''
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
arr[0]="😂"
arr[1]="😱"
arr[2]="👿"
arr[3]="💩"
arr[4]="🙏"
arr[5]="🙈"
arr[6]="🐐"
arr[7]="🤖"
arr[8]="🪿"
arr[9]="👻"
rand=$[$RANDOM % ${#arr[@]}]
git commit -m "chore(bot): ${arr[$rand]} update fava version to ${{ steps.get_fava_version.outputs.fava_version }}"
- name: Push changes
uses: ad-m/github-push-action@master
# uses: actions-js/push@master
if: steps.get_fava_version.outputs.fava_version != ''
with:
directory: "beancount/fava"
github_token: ${{ secrets.GITHUB_TOKEN }}