diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ffb9156..b52918d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,4 +13,4 @@ updates: schedule: interval: 'daily' ignore: - - dependency-name: 'python-telegram-bot' \ No newline at end of file + - dependency-name: 'python-telegram-bot' diff --git a/.github/workflows/build-and-push-generic.yaml b/.github/workflows/build-and-push-generic.yaml new file mode 100644 index 0000000..035ce42 --- /dev/null +++ b/.github/workflows/build-and-push-generic.yaml @@ -0,0 +1,12 @@ +name: Build and push +on: + pull_request_target: + paths: + - 'README**' + - 'LICENSE' + +jobs: + merge: + runs-on: ubuntu-latest + steps: + - run: 'echo "No build required"' diff --git a/.github/workflows/build-and-push-flexget-docker-images.yaml b/.github/workflows/build-and-push.yaml similarity index 86% rename from .github/workflows/build-and-push-flexget-docker-images.yaml rename to .github/workflows/build-and-push.yaml index b8e3d98..4ef8cdd 100644 --- a/.github/workflows/build-and-push-flexget-docker-images.yaml +++ b/.github/workflows/build-and-push.yaml @@ -1,10 +1,15 @@ -name: Build and push FlexGet Docker images - +name: Build and push on: push: branches: - 'main' + paths-ignore: + - 'README**' + - 'LICENSE' pull_request_target: + paths-ignore: + - 'README**' + - 'LICENSE' env: REGISTRY_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/flexget @@ -18,7 +23,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} + ref: ${{ github.event.pull_request.head.sha }} - id: platforms run: | @@ -56,6 +61,10 @@ jobs: platform=${{ matrix.platform }} echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/download-artifact@v4 with: name: bake-meta @@ -73,11 +82,10 @@ jobs: - id: bake uses: docker/bake-action@v5 with: - source: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.head_ref }} files: | ./docker-bake.hcl - cwd:///tmp/docker-metadata-action-bake.json - targets: image + /tmp/docker-metadata-action-bake.json + targets: all set: | *.tags= *.platform=${{ matrix.platform }} @@ -85,7 +93,7 @@ jobs: - run: | mkdir -p /tmp/digests - digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}" + digest="${{ fromJSON(steps.bake.outputs.metadata).all['containerimage.digest'] }}" touch "/tmp/digests/${digest#sha256:}" - uses: actions/upload-artifact@v4 @@ -127,4 +135,4 @@ jobs: run: | docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}") or startswith("${{ env.GHCR_IMAGE }}")) | "-t " + .) | - join(" ")' /tmp/docker-metadata-action-bake.json) $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) \ No newline at end of file + join(" ")' /tmp/docker-metadata-action-bake.json) $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) diff --git a/.github/workflows/dependabot-auto-merge.yaml b/.github/workflows/dependabot-auto-merge.yaml new file mode 100644 index 0000000..adcb08d --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yaml @@ -0,0 +1,22 @@ +# To use the workflow, make sure you have completed the following steps in repository settings: +# 1. Create a ruleset for 'main' branch: status check 'merge' is required. +# 2. Enable 'Allow auto-merge' in 'General'. +# Without above steps, the workflow enables Dependabot pull requests to be merged unconditionally. + +name: Dependabot auto-merge +# Uncomment the next line to enable the workflow. +# on: pull_request + +permissions: + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'dependabot[bot]' + steps: + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto -m "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/prompt-to-pull-built-images.yaml b/.github/workflows/prompt-to-pull-built-images.yaml new file mode 100644 index 0000000..070aa31 --- /dev/null +++ b/.github/workflows/prompt-to-pull-built-images.yaml @@ -0,0 +1,27 @@ +name: Prompt to pull built images +on: + pull_request_target: + types: [ opened ] + paths-ignore: + - 'README**' + - 'LICENSE' + +env: + REGISTRY_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/flexget + +jobs: + comment: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `To inspect the last successfully built Docker image based on the PR, run: + \`\`\`console + $ docker pull ${{ env.REGISTRY_IMAGE }}:pr-${{ github.event.number }} + \`\`\`` + }) diff --git a/Dockerfile b/Dockerfile index baed652..a20582f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,4 +25,4 @@ RUN set -eux; \ VOLUME /config /downloads WORKDIR /config EXPOSE 3539 -ENTRYPOINT ["/usr/bin/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/entrypoint.sh"] diff --git a/README-zh_CN.adoc b/README-zh_CN.adoc index 0a3c620..742d62d 100644 --- a/README-zh_CN.adoc +++ b/README-zh_CN.adoc @@ -13,9 +13,10 @@ endif::[] :repo: madwind/docker-flexget :image: madwind/flexget -image:https://github.com/{repo}/actions/workflows/build-and-push-flexget-docker-images.yaml/badge.svg[CI,link=https://github.com/{repo}/actions/workflows/build-and-push-flexget-docker-images.yaml] -image:https://img.shields.io/docker/image-size/{image}?arch=arm64&logo=docker&color=aqua[Docker Image Size,link=https://registry.hub.docker.com/r/{image}] +image:https://github.com/{repo}/actions/workflows/build-and-push.yaml/badge.svg[CI,link=https://github.com/{repo}/actions/workflows/build-and-push.yaml] +image:https://img.shields.io/docker/image-size/{image}?arch=arm64&logo=docker&logoColor=aqua&color=aqua[Docker Image Size,link=https://registry.hub.docker.com/r/{image}] image:https://badgen.net/docker/pulls/{image}?icon=docker&color=pink[Downloads,link=https://registry.hub.docker.com/r/{image}] +image:https://img.shields.io/endpoint?url=https%3A%2F%2Fmogyo.ro%2Fquart-apis%2Ftgmembercount%3Fchat_id%3Dflexget_qbittorrent_mod[Telegram Group,link=https://t.me/flexget_qbittorrent_mod] link:README.adoc[English] @@ -78,6 +79,8 @@ services: === 使用 GitHub Actions 构建 -. https://github.com/{repo}/fork[分叉]存储库。 -. 在 repository settings -> secrets and variables -> actions -> repository secrets,输入 DOCKERHUB_USERNAME 和 DOCKERHUB_TOKEN。 -. git push 到 `main` 分支将自动构建并推送 Docker 映像。 \ No newline at end of file +. https://github.com/{repo}/fork[复刻]存储库。 +. 在 repository settings -> secrets and variables -> actions -> repository secrets,输入 `DOCKERHUB_USERNAME` 和 `DOCKERHUB_TOKEN`。 +. 为你的存储库启用 Actions。 +因你的存储库在复刻时包含工作流,GitHub 禁止其在复刻上运行。footnote:[Dependabot 同样默认不会在复刻中启用,在 repository insights -> dependency graph -> dependabot 中启用它。] +. git push 到 `main` 分支将自动构建并推送 Docker 映像。footnote:[README 和 LICENSE 文件在排除列表中,对它们的更改不会触发构建。] diff --git a/README.adoc b/README.adoc index e219c57..e4adbe6 100644 --- a/README.adoc +++ b/README.adoc @@ -13,9 +13,10 @@ endif::[] :repo: madwind/docker-flexget :image: madwind/flexget -image:https://github.com/{repo}/actions/workflows/build-and-push-flexget-docker-images.yaml/badge.svg[CI,link=https://github.com/{repo}/actions/workflows/build-and-push-flexget-docker-images.yaml] -image:https://img.shields.io/docker/image-size/{image}?arch=arm64&logo=docker&color=aqua[Docker Image Size,link=https://registry.hub.docker.com/r/{image}] +image:https://github.com/{repo}/actions/workflows/build-and-push.yaml/badge.svg[CI,link=https://github.com/{repo}/actions/workflows/build-and-push.yaml] +image:https://img.shields.io/docker/image-size/{image}?arch=arm64&logo=docker&logoColor=aqua&color=aqua[Docker Image Size,link=https://registry.hub.docker.com/r/{image}] image:https://badgen.net/docker/pulls/{image}?icon=docker&color=pink[Downloads,link=https://registry.hub.docker.com/r/{image}] +image:https://img.shields.io/endpoint?url=https%3A%2F%2Fmogyo.ro%2Fquart-apis%2Ftgmembercount%3Fchat_id%3Dflexget_qbittorrent_mod[Telegram Group,link=https://t.me/flexget_qbittorrent_mod] link:README-zh_CN.adoc[简体中文] @@ -79,5 +80,7 @@ To build the FlexGet Docker image locally, in the project directory, run: === Build with GitHub Actions . https://github.com/{repo}/fork[Fork] the repository. -. In repository settings -> secrets and variables -> actions -> repository secrets, enter DOCKERHUB_USERNAME and DOCKERHUB_TOKEN. -. A git push to the `main` branch will automatically build and push the Docker image. \ No newline at end of file +. In repository settings -> secrets and variables -> actions -> repository secrets, enter `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN`. +. Enable Actions on your repository. +Because your repository contains workflow files when it is forked, GitHub disables them from running on your fork.footnote:[Dependabot is also not enabled on forks by default. Enable it in repository insights -> dependency graph -> dependabot.] +. A git push to the `main` branch will automatically build and push the Docker image.footnote:[README and LICENSE files are in the exclusion list, changes to them will not trigger a build.] diff --git a/docker-bake.hcl b/docker-bake.hcl index 041c3aa..a5e968e 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -2,27 +2,21 @@ variable "DEFAULT_TAG" { default = "flexget:latest" } -target "docker-metadata-action" { - tags = ["${DEFAULT_TAG}"] -} - group "default" { targets = ["local"] } -target "image" { - inherits = ["docker-metadata-action"] -} - target "local" { - inherits = ["image"] + tags = ["${DEFAULT_TAG}"] output = ["type=docker"] } +target "docker-metadata-action" {} + target "all" { - inherits = ["image"] + inherits = ["docker-metadata-action"] platforms = [ "linux/amd64", "linux/arm64" ] -} \ No newline at end of file +} diff --git a/requirements.txt b/requirements.txt index 9d229ab..f5923d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,4 @@ fuzzywuzzy==0.18.0 python-levenshtein==0.26.0 transmission-rpc==7.0.11 deluge-client==1.10.2 -flexget==3.11.49 \ No newline at end of file +flexget==3.11.49 diff --git a/root/defaults/config.example.yml b/root/defaults/config.example.yml index 57b9086..b9c65bd 100644 --- a/root/defaults/config.example.yml +++ b/root/defaults/config.example.yml @@ -5,4 +5,4 @@ web_server: tasks: example-task: rss: http://example.com/feed.xml - download: /downloads \ No newline at end of file + download: /downloads diff --git a/root/usr/bin/entrypoint.sh b/root/usr/bin/entrypoint.sh index efabe53..8dd7d29 100644 --- a/root/usr/bin/entrypoint.sh +++ b/root/usr/bin/entrypoint.sh @@ -36,4 +36,4 @@ fi chown -R flexget:flexget /config chown -R flexget:flexget /downloads -su flexget -c "/usr/local/bin/flexget -c /config/config.yml -l ${FG_LOGFILE:-flexget.log} -L ${FG_LOG_LEVEL:-info} daemon start --autoreload-config" \ No newline at end of file +su flexget -c "/usr/local/bin/flexget -c /config/config.yml -l ${FG_LOGFILE:-flexget.log} -L ${FG_LOG_LEVEL:-info} daemon start --autoreload-config"