Skip to content

nvchecker

nvchecker #7275

Workflow file for this run

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 */12 * * *"
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
- name: Send Email
shell: bash
# -F attachment=@${{ env.LOG_FILE }} \
run: |
LOG=$(cat ${{ env.LOG_FILE }}) \
RESULT=$(cat result.tmp) \
DATE=$(date +"%Y-%m-%d") \
&& [[ ! -z $LOG ]] || [[ ! -z $RESULT ]] \
&& curl \
-s \
--user 'api:${{ secrets.MAILGUN_API_KEY }}' \
https://api.mailgun.net/v3/${{ secrets.MAILGUN_DOMAIN_NAME }}/messages \
-F from='nvchecker <postmaster@${{ secrets.MAILGUN_DOMAIN_NAME }}>' \
-F to=${{ secrets.EMAIL_TO }} -F subject="New version check result · $DATE" \
-F text="$RESULT" --form-string html="<html><pre><code>$RESULT</code></pre><hr /><pre><code>$LOG</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@v4
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'