diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1544c9251..a664e5109 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -202,17 +202,24 @@ jobs: - name: Upload artifacts if: ${{ github.event_name != 'release' }} + working-directory: output/images/ env: AWS_ACCESS_KEY_ID: ${{ secrets.R2_OS_ARTIFACTS_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_OS_ARTIFACTS_KEY }} run: | aws s3 sync \ - output/images/ \ + ./ \ s3://${{ secrets.R2_OS_ARTIFACTS_BUCKET }}/${{ needs.prepare.outputs.version_full }}/ \ --exclude "*" \ --include "haos_*" \ --endpoint-url ${{ secrets.R2_OS_ARTIFACTS_ENDPOINT }} + ls haos_* | jq --raw-input | jq --slurp > "${{ needs.prepare.outputs.version_full }}.json" + aws s3 cp \ + "${{ needs.prepare.outputs.version_full }}.json" \ + s3://${{ secrets.R2_OS_ARTIFACTS_BUCKET }}/indexes/ \ + --endpoint-url ${{ secrets.R2_OS_ARTIFACTS_ENDPOINT }} + - name: Upload release assets if: ${{ github.event_name == 'release' }} uses: shogo82148/actions-upload-release-asset@v1 @@ -255,6 +262,33 @@ jobs: email: ${{ secrets.GIT_EMAIL }} token: ${{ secrets.GIT_TOKEN }} + - name: Regenerate artifacts index + if: ${{ github.event_name != 'release' }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.R2_OS_ARTIFACTS_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_OS_ARTIFACTS_KEY }} + run: | + aws s3api list-objects-v2 \ + --bucket "${{ secrets.R2_OS_ARTIFACTS_BUCKET }}" \ + --endpoint-url "${{ secrets.R2_OS_ARTIFACTS_ENDPOINT }}" \ + --prefix "indexes/" \ + --query 'Contents[].Key' | jq 'map(capture("indexes/(?[[:digit:]].+).json").version) | sort' > .os-artifacts/index.json + aws s3 sync \ + .os-artifacts/ \ + s3://${{ secrets.R2_OS_ARTIFACTS_BUCKET }}/ \ + --endpoint-url ${{ secrets.R2_OS_ARTIFACTS_ENDPOINT }} + + - name: Flush CloudFlare cache + run: | + curl --silent --show-error --fail -X POST \ + "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/purge_cache" \ + -H "Authorization: Bearer ${{ secrets.CF_TOKEN }}" \ + -H "Content-Type: application/json" \ + --data '{"files": [ + "https://os-artifacts.home-assistant.io/index.html", + "https://os-artifacts.home-assistant.io/index.json" + ] }' + - name: Bump Home Assistant OS ${{ needs.prepare.outputs.channel }} channel version uses: home-assistant/actions/helpers/version-push@master with: diff --git a/.os-artifacts/index.html b/.os-artifacts/index.html new file mode 100644 index 000000000..441da8ee5 --- /dev/null +++ b/.os-artifacts/index.html @@ -0,0 +1,82 @@ + + + + Home Assistant OS - development builds + + + + +

Home Assistant OS - development builds

+ +
+ + + \ No newline at end of file diff --git a/README.md b/README.md index 2f966dbb8..48193c3b3 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,4 @@ The Home Assistant Operating System documentation can be found on the [Home Assi The Development build GitHub Action Workflow is a manually triggered workflow which creates Home Assistant OS development builds. The development builds are -available at [os-builds.home-assistant.io](https://os-builds.home-assistant.io/). +available at [https://os-artifacts.home-assistant.io/index.html](https://os-artifacts.home-assistant.io/index.html).