mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-12-19 18:08:29 +00:00
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.0 to 6.0.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1af3b93b68...8e8c483db8)
---
updated-dependencies:
- dependency-name: actions/checkout
dependency-version: 6.0.1
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
103 lines
3.8 KiB
YAML
103 lines
3.8 KiB
YAML
name: Update artifacts index
|
|
|
|
on:
|
|
# Manual run for specified version
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: Version of HAOS to build index for
|
|
required: true
|
|
type: string
|
|
|
|
# Called by other workflows (e.g. build.yaml)
|
|
workflow_call:
|
|
inputs:
|
|
version:
|
|
description: Version of HAOS to build index for
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
R2_OS_ARTIFACTS_ID:
|
|
required: true
|
|
R2_OS_ARTIFACTS_KEY:
|
|
required: true
|
|
R2_OS_ARTIFACTS_BUCKET:
|
|
required: true
|
|
R2_OS_ARTIFACTS_ENDPOINT:
|
|
required: true
|
|
CF_ZONE:
|
|
required: true
|
|
CF_PURGE_TOKEN:
|
|
required: true
|
|
|
|
env:
|
|
PYTHON_VERSION: "3.13"
|
|
|
|
jobs:
|
|
build-index:
|
|
name: Build Home Assistant OS artifacts index
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Python version ${{ env.PYTHON_VERSION }}
|
|
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Install AWS CLI
|
|
run: pip install 'awscli<1.37.0'
|
|
|
|
- name: Create build index
|
|
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 "${{ inputs.version }}/" \
|
|
--query 'Contents[].Key' | jq 'map(split("/")[1]) | sort' > "${{ inputs.version }}.json"
|
|
aws s3 cp \
|
|
"${{ inputs.version }}.json" \
|
|
s3://${{ secrets.R2_OS_ARTIFACTS_BUCKET }}/indexes/ \
|
|
--endpoint-url "${{ secrets.R2_OS_ARTIFACTS_ENDPOINT }}"
|
|
|
|
- name: Regenerate artifacts index
|
|
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/(?<version>[[: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: |
|
|
# Create purge list of all artifacts
|
|
jq -r '. | map("https://os-artifacts.home-assistant.io/${{ inputs.version }}/" + .) | join("\n")' < "${{ inputs.version }}.json" > purge_list
|
|
# Add indexes to purge list too
|
|
echo "https://os-artifacts.home-assistant.io/indexes/${{ inputs.version }}.json" >> purge_list
|
|
echo "https://os-artifacts.home-assistant.io/index.html" >> purge_list
|
|
echo "https://os-artifacts.home-assistant.io/index.json" >> purge_list
|
|
# Split to chunks of 30 files (limit of CF API)
|
|
split -d -l30 purge_list purge_list_chunked
|
|
# Convert chunked lists to JSON arrays and call CF purge API
|
|
for f in purge_list_chunked*; do
|
|
files=$(jq -R -s 'split("\n")[:-1]' < "$f")
|
|
curl --silent --show-error --fail -X POST \
|
|
"https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/purge_cache" \
|
|
-H "Authorization: Bearer ${{ secrets.CF_PURGE_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
--data "{\"files\": ${files}}"
|
|
done
|