mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-23 13:06:29 +00:00
Separate artifacts index update into separate workflow (#2888)
* Separate artifacts index update into separate workflow * Apply suggestions from code review Co-authored-by: Jan Čermák <sairon@users.noreply.github.com> --------- Co-authored-by: Jan Čermák <sairon@users.noreply.github.com>
This commit is contained in:
parent
54cab43ea3
commit
2e8b66d283
75
.github/workflows/artifacts-index.yaml
vendored
Normal file
75
.github/workflows/artifacts-index.yaml
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: "3.10"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-index:
|
||||||
|
name: Build Home Assistant OS artifacts index
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Setup Python version ${{ env.PYTHON_VERSION }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
|
- name: Install AWS CLI
|
||||||
|
run: pip install awscli
|
||||||
|
|
||||||
|
- 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 "${{ github.event.inputs.version }}/" \
|
||||||
|
--query 'Contents[].Key' | jq 'map(split("/")[1]) | sort' > "${{ github.event.inputs.version }}.json"
|
||||||
|
aws s3 cp \
|
||||||
|
"${{ github.event.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: |
|
||||||
|
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": [
|
||||||
|
"https://os-artifacts.home-assistant.io/index.html",
|
||||||
|
"https://os-artifacts.home-assistant.io/index.json"
|
||||||
|
] }'
|
51
.github/workflows/build.yaml
vendored
51
.github/workflows/build.yaml
vendored
@ -208,12 +208,6 @@ jobs:
|
|||||||
--include "haos_*" \
|
--include "haos_*" \
|
||||||
--endpoint-url ${{ secrets.R2_OS_ARTIFACTS_ENDPOINT }}
|
--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
|
- name: Upload release assets
|
||||||
if: ${{ github.event_name == 'release' }}
|
if: ${{ github.event_name == 'release' }}
|
||||||
uses: shogo82148/actions-upload-release-asset@v1
|
uses: shogo82148/actions-upload-release-asset@v1
|
||||||
@ -247,6 +241,14 @@ jobs:
|
|||||||
needs: [ build, prepare ]
|
needs: [ build, prepare ]
|
||||||
uses: ./.github/workflows/test.yaml
|
uses: ./.github/workflows/test.yaml
|
||||||
|
|
||||||
|
update_index:
|
||||||
|
name: Update artifacts index
|
||||||
|
if: ${{ github.event_name != 'release' }}
|
||||||
|
needs: [ build, prepare ]
|
||||||
|
uses: home-assistant/operating-system/.github/workflows/artifacts-index.yaml@dev
|
||||||
|
with:
|
||||||
|
version: ${{ needs.prepare.outputs.version_full }}
|
||||||
|
|
||||||
bump_version:
|
bump_version:
|
||||||
name: Bump ${{ needs.prepare.outputs.channel }} channel version
|
name: Bump ${{ needs.prepare.outputs.channel }} channel version
|
||||||
if: ${{ github.repository == 'home-assistant/operating-system' }}
|
if: ${{ github.repository == 'home-assistant/operating-system' }}
|
||||||
@ -267,43 +269,6 @@ jobs:
|
|||||||
email: ${{ secrets.GIT_EMAIL }}
|
email: ${{ secrets.GIT_EMAIL }}
|
||||||
token: ${{ secrets.GIT_TOKEN }}
|
token: ${{ secrets.GIT_TOKEN }}
|
||||||
|
|
||||||
- name: Setup Python version ${{ env.PYTHON_VERSION }}
|
|
||||||
if: ${{ github.event_name != 'release' }}
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
|
||||||
|
|
||||||
- name: Install AWS CLI
|
|
||||||
if: ${{ github.event_name != 'release' }}
|
|
||||||
run: pip install awscli
|
|
||||||
|
|
||||||
- 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/(?<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: |
|
|
||||||
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": [
|
|
||||||
"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
|
- name: Bump Home Assistant OS ${{ needs.prepare.outputs.channel }} channel version
|
||||||
uses: home-assistant/actions/helpers/version-push@master
|
uses: home-assistant/actions/helpers/version-push@master
|
||||||
with:
|
with:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user