|
11 | 11 | branches: [main] |
12 | 12 | types: |
13 | 13 | - completed |
14 | | -concurrency: |
15 | | - group: deploy |
16 | 14 |
|
17 | 15 | permissions: |
18 | 16 | contents: read |
19 | 17 | packages: write |
20 | 18 |
|
21 | 19 | jobs: |
22 | | - information: |
23 | | - if: | |
| 20 | + deploy: |
| 21 | + if: > |
24 | 22 | github.event_name == 'release' |
25 | 23 | || ( |
26 | 24 | github.event_name == 'workflow_run' |
27 | 25 | && github.event.workflow_run.conclusion == 'success' |
28 | 26 | ) |
29 | | - name: ℹ️ Gather app (add-on) information |
30 | | - runs-on: ubuntu-latest |
31 | | - outputs: |
32 | | - architectures: ${{ steps.information.outputs.architectures }} |
33 | | - build: ${{ steps.information.outputs.build }} |
34 | | - description: ${{ steps.information.outputs.description }} |
35 | | - environment: ${{ steps.release.outputs.environment }} |
36 | | - name: ${{ steps.information.outputs.name }} |
37 | | - slug: ${{ steps.override.outputs.slug }} |
38 | | - target: ${{ steps.information.outputs.target }} |
39 | | - version: ${{ steps.release.outputs.version }} |
40 | | - steps: |
41 | | - - name: ⤵️ Check out code from GitHub |
42 | | - uses: actions/checkout@v6.0.1 |
43 | | - - name: 🚀 Run app (add-on) information action |
44 | | - id: information |
45 | | - uses: homeassistant-apps/action-app-information@v2 |
46 | | - - name: 🚀 Process possible slug override |
47 | | - id: override |
48 | | - run: | |
49 | | - slug="${{ steps.information.outputs.slug }}" |
50 | | - if [[ ! -z "${{ inputs.slug }}" ]]; then |
51 | | - slug="${{ inputs.slug }}" |
52 | | - fi |
53 | | - echo "slug=$slug" >> $GITHUB_OUTPUT |
54 | | - - name: ℹ️ Gather version and environment |
55 | | - id: release |
56 | | - run: | |
57 | | - sha="${{ github.sha }}" |
58 | | - environment="edge" |
59 | | - version="${sha:0:7}" |
60 | | - if [[ "${{ github.event_name }}" = "release" ]]; then |
61 | | - version="${{ github.event.release.tag_name }}" |
62 | | - version="${version,,}" |
63 | | - version="${version#v}" |
64 | | - environment="stable" |
65 | | - if [[ "${{ github.event.release.prerelease }}" = "true" ]]; then |
66 | | - environment="beta" |
67 | | - fi |
68 | | - fi |
69 | | -
|
70 | | - echo "environment=$environment" >> $GITHUB_OUTPUT |
71 | | - echo "version=$version" >> $GITHUB_OUTPUT |
72 | | -
|
73 | | - deploy: |
74 | | - name: 👷 Build & Deploy ${{ matrix.architecture }} |
75 | | - needs: information |
76 | | - runs-on: ubuntu-latest |
77 | | - strategy: |
78 | | - matrix: |
79 | | - architecture: ${{ fromJson(needs.information.outputs.architectures) }} |
80 | | - steps: |
81 | | - - name: ⤵️ Check out code from GitHub |
82 | | - uses: actions/checkout@v6.0.1 |
83 | | - - name: 🏗 Set up QEMU |
84 | | - uses: docker/setup-qemu-action@v3.7.0 |
85 | | - - name: 🏗 Set up Docker Buildx |
86 | | - uses: docker/setup-buildx-action@v3.12.0 |
87 | | - - name: ℹ️ Compose build flags |
88 | | - id: flags |
89 | | - run: | |
90 | | - echo "date=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT |
91 | | - if [[ "${{ matrix.architecture}}" = "amd64" ]]; then |
92 | | - echo "platform=linux/amd64" >> $GITHUB_OUTPUT |
93 | | - elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then |
94 | | - echo "platform=linux/arm64/v8" >> $GITHUB_OUTPUT |
95 | | - else |
96 | | - echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}" |
97 | | - exit 1 |
98 | | - fi |
99 | | - - name: 🔤 Normalize registry owner |
100 | | - id: registry |
101 | | - run: | |
102 | | - owner="${GITHUB_REPOSITORY_OWNER,,}" |
103 | | - echo "owner=$owner" >> "$GITHUB_OUTPUT" |
104 | | - - name: 🏗 Login to GitHub Container Registry |
105 | | - uses: docker/login-action@v3.6.0 |
106 | | - with: |
107 | | - registry: ghcr.io |
108 | | - username: ${{ steps.registry.outputs.owner }} |
109 | | - password: ${{ secrets.GITHUB_TOKEN }} |
110 | | - - name: 🚀 Build |
111 | | - uses: docker/build-push-action@v6.18.0 |
112 | | - with: |
113 | | - load: true |
114 | | - # yamllint disable rule:line-length |
115 | | - tags: | |
116 | | - ghcr.io/${{ steps.registry.outputs.owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }} |
117 | | - ghcr.io/${{ steps.registry.outputs.owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }} |
118 | | - # yamllint enable rule:line-length |
119 | | - context: ${{ needs.information.outputs.target }} |
120 | | - file: ${{ needs.information.outputs.target }}/Dockerfile |
121 | | - cache-from: type=gha,scope=${{ needs.information.outputs.slug }}-${{ matrix.architecture }} |
122 | | - cache-to: type=gha,mode=max,scope=${{ needs.information.outputs.slug }}-${{ matrix.architecture }} |
123 | | - platforms: ${{ steps.flags.outputs.platform }} |
124 | | - build-args: | |
125 | | - BUILD_ARCH=${{ matrix.architecture }} |
126 | | - BUILD_DATE=${{ steps.flags.outputs.date }} |
127 | | - BUILD_DESCRIPTION=${{ needs.information.outputs.description }} |
128 | | - BUILD_NAME=${{ needs.information.outputs.name }} |
129 | | - BUILD_REF=${{ github.sha }} |
130 | | - BUILD_REPOSITORY=${{ github.repository }} |
131 | | - BUILD_VERSION=${{ needs.information.outputs.version }} |
132 | | - # yamllint disable rule:line-length |
133 | | - - name: 🚀 Push |
134 | | - run: | |
135 | | - docker push \ |
136 | | - "ghcr.io/${{ steps.registry.outputs.owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}" |
137 | | - docker push \ |
138 | | - "ghcr.io/${{ steps.registry.outputs.owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}" |
139 | | - # yamllint enable rule:line-length |
140 | | - publish-edge: |
141 | | - name: 📢 Publish to edge repository |
142 | | - if: needs.information.outputs.environment == 'edge' |
143 | | - needs: |
144 | | - - information |
145 | | - - deploy |
146 | | - environment: |
147 | | - name: ${{ needs.information.outputs.environment }} |
148 | | - runs-on: ubuntu-latest |
149 | | - steps: |
150 | | - - name: 🚀 Dispatch update signal - homeassistant-apps/repository-edge |
151 | | - uses: peter-evans/repository-dispatch@v4.0.1 |
152 | | - with: |
153 | | - token: ${{ secrets.PAT_BRENNER_BOT }} |
154 | | - repository: ${{ github.repository_owner }}/repository-edge |
155 | | - event-type: update |
156 | | - client-payload: > |
157 | | - { |
158 | | - "addon": "${{ needs.information.outputs.slug }}", |
159 | | - "name": "${{ needs.information.outputs.name }}", |
160 | | - "repository": "${{ github.repository }}", |
161 | | - "version": "${{ needs.information.outputs.version }}" |
162 | | - } |
163 | | - - name: 🚀 Dispatch repository updater update signal - brenner-tobias/ha-addons-edge |
164 | | - uses: peter-evans/repository-dispatch@v4.0.1 |
165 | | - with: |
166 | | - token: ${{ secrets.PAT_BRENNER_BOT }} |
167 | | - repository: brenner-tobias/ha-addons-edge |
168 | | - event-type: update |
169 | | - client-payload: > |
170 | | - { |
171 | | - "addon": "${{ needs.information.outputs.slug }}", |
172 | | - "name": "${{ needs.information.outputs.name }}", |
173 | | - "repository": "${{ github.repository }}", |
174 | | - "version": "${{ needs.information.outputs.version }}" |
175 | | - } |
176 | | -
|
177 | | - publish-stable: |
178 | | - name: 📢 Publish to stable repository |
179 | | - if: needs.information.outputs.environment == 'stable' |
180 | | - needs: |
181 | | - - information |
182 | | - - deploy |
183 | | - environment: |
184 | | - name: ${{ needs.information.outputs.environment }} |
185 | | - runs-on: ubuntu-latest |
186 | | - steps: |
187 | | - - name: 🚀 Dispatch repository updater update signal - homeassistant-apps/repository |
188 | | - uses: peter-evans/repository-dispatch@v4.0.1 |
189 | | - with: |
190 | | - token: ${{ secrets.PAT_BRENNER_BOT }} |
191 | | - repository: ${{ github.repository_owner }}/repository |
192 | | - event-type: update |
193 | | - client-payload: > |
194 | | - { |
195 | | - "addon": "${{ needs.information.outputs.slug }}", |
196 | | - "name": "${{ needs.information.outputs.name }}", |
197 | | - "repository": "${{ github.repository }}", |
198 | | - "version": "${{ github.event.release.tag_name }}" |
199 | | - } |
200 | | - - name: 🚀 Dispatch repository updater update signal - brenner-tobias/ha-addons |
201 | | - uses: peter-evans/repository-dispatch@v4.0.1 |
202 | | - with: |
203 | | - token: ${{ secrets.PAT_BRENNER_BOT }} |
204 | | - repository: brenner-tobias/ha-addons |
205 | | - event-type: update |
206 | | - client-payload: > |
207 | | - { |
208 | | - "addon": "${{ needs.information.outputs.slug }}", |
209 | | - "name": "${{ needs.information.outputs.name }}", |
210 | | - "repository": "${{ github.repository }}", |
211 | | - "version": "${{ github.event.release.tag_name }}" |
212 | | - } |
| 27 | + uses: ./.github/workflows/upstream/deploy.yaml |
| 28 | + secrets: inherit |
| 29 | + with: |
| 30 | + event_name: ${{ github.event_name }} |
| 31 | + release_prerelease: ${{ github.event.release.prerelease || false }} |
| 32 | + release_tag_name: ${{ github.event.release.tag_name || '' }} |
0 commit comments