From 048208b86736590e304a687e22bb917c3f1f278f Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sun, 15 Dec 2024 18:48:38 +0900 Subject: [PATCH 1/4] build image in pr --- .github/workflows/deploy-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-image.yml b/.github/workflows/deploy-image.yml index 27051a1..5338702 100644 --- a/.github/workflows/deploy-image.yml +++ b/.github/workflows/deploy-image.yml @@ -37,7 +37,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | # almost same as action default - type=ref,event=branch + type=ref,event=pr type=ref,event=tag,pattern={{raw}} # type=ref,event=workflow_dispatch type=sha,event=workflow_dispatch From 8f7c09ef679f4d57b3fa21034fa551b4c1d49f65 Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sun, 15 Dec 2024 18:49:49 +0900 Subject: [PATCH 2/4] build docker image in PRs --- .github/workflows/{deploy-image.yml => build-image.yml} | 1 + 1 file changed, 1 insertion(+) rename .github/workflows/{deploy-image.yml => build-image.yml} (98%) diff --git a/.github/workflows/deploy-image.yml b/.github/workflows/build-image.yml similarity index 98% rename from .github/workflows/deploy-image.yml rename to .github/workflows/build-image.yml index 5338702..a48d04b 100644 --- a/.github/workflows/deploy-image.yml +++ b/.github/workflows/build-image.yml @@ -2,6 +2,7 @@ name: Build Docker image on: workflow_dispatch: + pull_request: push: tags: - "v**" From 7516cafca46516dbe42b8b8811b151be8cf98881 Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sun, 15 Dec 2024 19:00:20 +0900 Subject: [PATCH 3/4] use global pybabel in Dockerfile --- Dockerfile | 2 +- Makefile | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 97c955d..a1fb759 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,4 @@ WORKDIR /app EXPOSE 5000 -RUN make babel-update-mo +RUN BIN_PREFIX=/usr/local/bin make babel-update-mo diff --git a/Makefile b/Makefile index 594e2f3..85dfd00 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ PYTEST_COV_ARGS = +BIN_PREFIX ?= venv/bin + FORCE: ; create-venv: @@ -44,11 +46,11 @@ test_logging: venv/bin/pytest --capture=sys --log-cli-level=DEBUG tests/base/test_logging.py babel-update-po: - venv/bin/pybabel extract -F babel.cfg -k lazy_gettext -k hardcode_text -o messages.pot app - venv/bin/pybabel update -i messages.pot -d app/translations + $(BIN_PREFIX)/pybabel extract -F babel.cfg -k lazy_gettext -k hardcode_text -o messages.pot app + $(BIN_PREFIX)/pybabel update -i messages.pot -d app/translations babel-update-mo: babel-update-po - venv/bin/pybabel compile -d app/translations + $(BIN_PREFIX)/pybabel compile -d app/translations babel-translate-po: venv/bin/python app/scripts/fill_zh_translations.py From da6e3709b836cef8de1524dbf798aa0affcf892f Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sun, 15 Dec 2024 19:11:59 +0900 Subject: [PATCH 4/4] skip image push in pr event --- .github/workflows/build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index a48d04b..484bcb8 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -50,7 +50,7 @@ jobs: uses: docker/build-push-action@v6.9.0 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} build-args: MOEFLOW_BUILD_ID=${{ github.repository }}:${{ github.ref }}:${{ github.sha }} cache-from: