Skip to content

Commit

Permalink
ci(github): Add R2 workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cedws committed Nov 14, 2024
1 parent 7a9cd44 commit bfd6fa6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/r2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run R2 upload

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6

- name: Download
run: just run -patch-only -dir Wizard101

- name: Set version
run: echo "WIZARD101_REVISION=$(cat Wizard101/Bin/revision.dat)" >> $GITHUB_ENV

- name: Sync
env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
run: aws s3 cp --region weur --recursive --endpoint-url https://394cb23f1dbebe9dabf6bda93f01727e.r2.cloudflarestorage.com Wizard101 s3://wizard101/$WIZARD101_REVISION
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,15 @@ func (p *patchClient) request(ctx context.Context, url string) (io.ReadCloser, e
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", "KingsIsle Patcher")

resp, err := p.httpClient.Do(req)
if err != nil {
return nil, err
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
return nil, fmt.Errorf("unexpected status code for url %s: %d", url, resp.StatusCode)
}

return resp.Body, err
Expand Down

0 comments on commit bfd6fa6

Please sign in to comment.