-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(beancount): add fava docker build workflow
Signed-off-by: yangbin <[email protected]>
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 $latest_version | sed 's/v//g')" >> $GITHUB_ENV | ||
fi | ||
- name: Build and push Docker images | ||
uses: docker/build-push-action@v6 | ||
if: steps.get_fava_version.outputs.fava_version != '' | ||
with: | ||
context: beancount/fava | ||
file: ./beancount/fava/Dockerfile | ||
builder: ${{ steps.buildx.outputs.name }} | ||
platforms: linux/arm64,linux/amd64 | ||
build-args: | | ||
FAVA_PIP_VERSION=$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_PIP_VERSION="[^"]*"/FAVA_PIP_VERSION="'"$fava_pip_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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# https://github.com/yegle/fava-docker | ||
# https://github.com/swissmanu/docker-fava | ||
|
||
FROM bitnami/python:3.12-debian-12 | ||
|
||
ARG FAVA_PIP_VERSION="1.27.3" | ||
ENV FAVA_PIP_VERSION=$FAVA_PIP_VERSION \ | ||
FAVA_HOST="0.0.0.0" \ | ||
BEANCOUNT_FILE="/ledger/main.beancount" | ||
|
||
EXPOSE 5000 | ||
ENTRYPOINT [ "fava" ] | ||
|
||
COPY requirements.txt . | ||
RUN pip3 install fava==$FAVA_PIP_VERSION \ | ||
&& pip3 install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# https://github.com/dallaslu/beancount-periodic | ||
beancount-periodic==0.1.2 | ||
# https://github.com/andreasgerstmayr/fava-dashboards | ||
# https://github.com/polarmutex/fava-envelope |