nvchecker #8203
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
name: nvchecker | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
paths: | |
- "config.toml" | |
- ".github/workflows/nvchecker.yml" | |
pull_request: | |
branches: | |
- master | |
paths: | |
- "config.toml" | |
- ".github/workflows/nvchecker.yml" | |
schedule: | |
- cron: "0 8,20 * * *" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
check-new-versions: | |
name: Check New Versions | |
runs-on: ubuntu-latest | |
container: | |
# image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
image: ghcr.io/sunlei/nvchecker | |
credentials: | |
username: ${{ github.actor }} | |
password: ${{ secrets.github_token }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set environment variables | |
run: | | |
echo "LOG_FILE=nvchecker_$(date +'%Y-%m-%d_%H-%M-%S').log" >> $GITHUB_ENV | |
sed -i -e "s/__GITHUB_ACCESS_TOKEN__/${{ secrets.GITHUB_TOKEN }}/g" keyfile.toml | |
- name: Check version | |
run: | | |
nvchecker --file config.toml --keyfile keyfile.toml 2>&1 | tee ${{ env.LOG_FILE }} | |
nvcmp --file config.toml > result.tmp | |
nvtake --file config.toml --all | |
# --form-string html="<html><pre><code>$RESULT</code></pre><hr /><pre><code>$LOG</code></pre></html>" \ | |
# LOG=$(cat ${{ env.LOG_FILE }}) \ | |
- name: Send Email | |
shell: bash | |
run: | | |
RESULT=$(cat result.tmp) \ | |
DATE=$(date +"%Y-%m-%d") \ | |
&& [[ -f ${{ env.LOG_FILE }} ]] || [[ ! -z $RESULT ]] \ | |
&& curl \ | |
-s \ | |
--user 'api:${{ secrets.MAILGUN_API_KEY }}' \ | |
https://api.mailgun.net/v3/${{ secrets.MAILGUN_DOMAIN_NAME }}/messages \ | |
-H 'Content-Type: multipart/form-data' \ | |
-F from='nvchecker <postmaster@${{ secrets.MAILGUN_DOMAIN_NAME }}>' \ | |
-F to=${{ secrets.EMAIL_TO }} \ | |
-F subject="New version check result · $DATE" \ | |
-F [email protected] \ | |
-F attachment=@${{ env.LOG_FILE }} \ | |
--form-string html="<html><pre><code>$RESULT</code></pre></html>" \ | |
|| echo "No new versions" \ | |
rm -f result.tmp ${{ env.LOG_FILE }} | |
# - https://github.com/actions/runner/issues/2033 | |
# - https://github.com/actions/checkout/issues/1048 | |
# - https://github.com/actions/runner-images/issues/6775 | |
- name: Fix git safe.directory in container | |
run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} | |
- name: Commit version record files | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "chore: apply version record files changes" | |
# branch: ${{ github.head_ref }} | |
branch: master | |
commit_options: "--no-verify --signoff" | |
file_pattern: ./*.json | |
repository: . | |
commit_user_name: GitHub Actions Bot | |
commit_user_email: [email protected] | |
commit_author: GitHub Actions Bot <[email protected]> | |
# - name: nvchecker-action | |
# id: nvchecker-action | |
# uses: guizai/nvchecker-action@master | |
# with: | |
# source-file: 'config.toml' |