定时任务-壁纸定时保存 #881
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
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: 定时任务-壁纸定时保存 | |
on: | |
schedule: | |
# UTC时间与北京时间8小时时差 | |
# UTC时间 18点执行一次,即UTC+8北京时间 2点执行一次 | |
- cron: '0 18 * * *' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# 设置服务器时区为东八区 | |
- name: Set time zone | |
run: sudo timedatectl set-timezone 'Asia/Shanghai' | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
- name: Run Java Application | |
run: java -jar target/image-save-jar-with-dependencies.jar | |
- name: Clear target | |
run: rm -rf target/ | |
- name: Commit files | |
run: | | |
git config --local user.email "wefashe@qq.com" | |
git config --local user.name "Java CI" | |
git add . | |
git commit -m "$(git config user.name) Auto Save Wallpaper At `TZ=UTC-8 date +%Y-%m-%d\ %H:%M:%S`" | |
continue-on-error: true | |
- name: Check on failures | |
if: steps.commit.outputs.status == 'failure' | |
run: exit 1 | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.MY_GIT_TOKEN }} | |
branch: main |