Files
cedict/.github/workflows/update.yml
T
Rodolfo Carvalho 6f27882907 Bump Go version and drop action/setup-go (#9)
Modern Go toolchains (available at the base image) can automatically
install the required version of Go based on the `go.mod` file, so we can
remove the `actions/setup-go` step from the workflow.

We keep the minimum required Go version in the `go.mod` file for broad
compatibility (1.19), but we use a more recent version when interacting
with the code (e.g. `go test` in the existing update.yml workflow).

    go get toolchain@latest

https://go.dev/blog/toolchain#:~:text=Or%20if%20you%20want%20to%20start%20using,toolchain%20version%20using%20the%20GOTOOLCHAIN%20environment%20variable.
2026-08-01 11:15:17 +02:00

59 lines
1.7 KiB
YAML

name: "Update CC-CEDICT"
on:
workflow_dispatch:
push:
branches:
- "main"
paths:
- ".github/workflows/update.yml"
- "cedict_1_0_ts_utf-8_mdbg.txt"
- "*_test.go"
schedule:
- cron: "0 9 * * *"
permissions:
contents: "write"
defaults:
run:
shell: "bash"
concurrency:
group: "update-${{ github.ref }}"
cancel-in-progress: true
jobs:
update:
name: "Update CC-CEDICT"
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- uses: "actions/checkout@v7"
- name: "Configure Git"
run: |
git config user.name "Rodolfo Carvalho"
git config user.email "88819+rhcarvalho@users.noreply.github.com"
- name: "Download"
run: |
URL='https://www.mdbg.net/chinese/export/cedict/cedict_1_0_ts_utf-8_mdbg.txt.gz'
curl -L ${URL} | gunzip > cedict_1_0_ts_utf-8_mdbg.txt
- name: "Check for changes"
id: "diff"
run: |
git add -- cedict_1_0_ts_utf-8_mdbg.txt
git diff --cached --stat
echo "::set-output name=changed::$(git diff --cached --quiet; echo $?)"
- name: "Update metadata"
if: "fromJSON(steps.diff.outputs.changed)"
run: |
awk -f meta -v RS='\r\n' cedict_1_0_ts_utf-8_mdbg.txt >> meta.csv
git add -- meta.csv
- name: "Commit"
if: "fromJSON(steps.diff.outputs.changed)"
run: |
RELEASE_DATE="$(awk -f release_date -v RS='\r\n' cedict_1_0_ts_utf-8_mdbg.txt)"
git commit -m "CC-CEDICT ${RELEASE_DATE}"
- name: "Test"
if: "fromJSON(steps.diff.outputs.changed)"
run: "go test -v -count=1"
- name: Push
if: "fromJSON(steps.diff.outputs.changed)"
run: |
git push