Call workflow for addon with dev version (#6549)

This commit is contained in:
Jesse Hills 2024-04-17 15:32:19 +12:00 committed by GitHub
parent 0af26fdfd4
commit ca5d38f413
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,14 +17,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
tag: ${{ steps.tag.outputs.tag }} tag: ${{ steps.tag.outputs.tag }}
branch_build: ${{ steps.tag.outputs.branch_build }}
steps: steps:
- uses: actions/checkout@v4.1.1 - uses: actions/checkout@v4.1.1
- name: Get tag - name: Get tag
id: tag id: tag
# yamllint disable rule:line-length # yamllint disable rule:line-length
run: | run: |
if [[ "$GITHUB_EVENT_NAME" = "release" ]]; then if [[ "${{ github.event_name }}" = "release" ]]; then
TAG="${GITHUB_REF#refs/tags/}" TAG="${{ github.event.release.tag_name}}"
BRANCH_BUILD="false"
else else
TAG=$(cat esphome/const.py | sed -n -E "s/^__version__\s+=\s+\"(.+)\"$/\1/p") TAG=$(cat esphome/const.py | sed -n -E "s/^__version__\s+=\s+\"(.+)\"$/\1/p")
today="$(date --utc '+%Y%m%d')" today="$(date --utc '+%Y%m%d')"
@ -32,9 +34,13 @@ jobs:
BRANCH=${GITHUB_REF#refs/heads/} BRANCH=${GITHUB_REF#refs/heads/}
if [[ "$BRANCH" != "dev" ]]; then if [[ "$BRANCH" != "dev" ]]; then
TAG="${TAG}-${BRANCH}" TAG="${TAG}-${BRANCH}"
BRANCH_BUILD="true"
else
BRANCH_BUILD="false"
fi fi
fi fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "branch_build=${BRANCH_BUILD}" >> $GITHUB_OUTPUT
# yamllint enable rule:line-length # yamllint enable rule:line-length
deploy-pypi: deploy-pypi:
@ -197,22 +203,28 @@ jobs:
$(printf '${{ steps.tags.outputs.image }}@sha256:%s ' *) $(printf '${{ steps.tags.outputs.image }}@sha256:%s ' *)
deploy-ha-addon-repo: deploy-ha-addon-repo:
if: github.repository == 'esphome/esphome' && github.event_name == 'release' if: github.repository == 'esphome/esphome' && needs.init.outputs.branch_build == 'false'
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [deploy-manifest] needs:
- init
- deploy-manifest
steps: steps:
- name: Trigger Workflow - name: Trigger Workflow
uses: actions/github-script@v7.0.1 uses: actions/github-script@v7.0.1
with: with:
github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }} github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }}
script: | script: |
let description = "ESPHome";
if (context.eventName == "release") {
description = ${{ toJSON(github.event.release.body) }};
}
github.rest.actions.createWorkflowDispatch({ github.rest.actions.createWorkflowDispatch({
owner: "esphome", owner: "esphome",
repo: "home-assistant-addon", repo: "home-assistant-addon",
workflow_id: "bump-version.yml", workflow_id: "bump-version.yml",
ref: "main", ref: "main",
inputs: { inputs: {
version: "${{ github.event.release.tag_name }}", version: "${{ needs.init.outputs.tag }}",
content: ${{ toJSON(github.event.release.body) }} content: description
} }
}) })