Download and Unzip Artifact #245
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: Download and Unzip Artifact | |
on: | |
schedule: | |
- cron: '0 */4 * * *' | |
push: | |
workflow_dispatch: | |
jobs: | |
download_and_unzip: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Get latest run ID | |
id: get_run_id | |
run: | | |
latest_run_id=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/Cats-Team/AdRules/actions/workflows/autoupdate.yml/runs | jq '.workflow_runs[0].id') | |
echo "Latest run ID: $latest_run_id" | |
echo "::set-output name=run_id::$latest_run_id" | |
- uses: actions/download-artifact@v4 | |
with: | |
name: archive.tar.gz | |
github-token: ${{ secrets.GITHUB_TOKEN }} # token with actions:read permissions on target repo | |
repository: Cats-Team/AdRules | |
run-id: ${{ steps.get_run_id.outputs.run_id }} | |
#path: artifact.tar | |
- name: Unzip Artifact | |
run: | | |
#unzip artifact.zip -d ./ | |
tar -xvf archive.tar.gz -C ./ | |
- name: Generate uptime.txt | |
run: | | |
echo $(TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S') > uptime.txt | |
- name: Commit and Push Changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m "Add latest artifact" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |