forked from hacs/default
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Upload removed file to R2 action (hacs#1669)
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Upload removed file to R2 | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- removed | ||
|
||
concurrency: | ||
cancel-in-progress: true | ||
group: upload-removed | ||
|
||
jobs: | ||
removed: | ||
runs-on: ubuntu-latest | ||
name: Removed | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
id: python | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Install AWS CLI | ||
run: | | ||
pip3 install \ | ||
--disable-pip-version-check install \ | ||
--ignore-installed \ | ||
awscli | ||
- name: Handle the removed file | ||
run: | | ||
mkdir -p upload/removed | ||
jq -c . < removed > upload/removed/data.json | ||
jq -c '[.[].repository]' < removed > upload/removed/repositories.json | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: removed | ||
path: upload/removed | ||
if-no-files-found: error | ||
|
||
- name: Upload to R2 | ||
run: | | ||
aws s3 sync \ | ||
upload/removed \ | ||
s3://data-v2/removed \ | ||
--endpoint-url ${{ secrets.CF_R2_ENDPOINT_DATA }} | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_SECRET_ACCESS_KEY }} | ||
|
||
- name: Discord notification | ||
if: ${{ github.event_name == 'schedule' && failure() }} | ||
run: | | ||
curl \ | ||
-H "Content-Type: application/json" \ | ||
-d '{"username": "GitHub action failure", "content": "[Scheduled action failed!](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})"}' \ | ||
${{ secrets.DISCORD_WEBHOOK_ACTION_FAILURE }} |