Skip to content

Commit

Permalink
🤹 ci (actions): Manage multiple addons in the same repository - first…
Browse files Browse the repository at this point in the history
… commit
  • Loading branch information
dianlight committed Feb 23, 2024
1 parent b88fdac commit 2e73f1d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 77 deletions.
42 changes: 27 additions & 15 deletions .github/workflows/docker-image-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,54 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: ✍🏼 version SambaNAs
- name: 📽️ Extract dev branch project name
shell: bash
run: echo "name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/devrelease/}}" >> $GITHUB_OUTPUT
id: extract_project

- name: ✍🏼 version ${{ steps.extract_project.outputs.name }}
id: version_get
uses: endaft/[email protected]
with:
file: ./${{ steps.extract_project.outputs.name }}/config.yaml
path: version
get: true

- name: 📽️ Identify SemVer ${{ steps.version_get.outputs.value_old }} suffix
shell: bash
run: echo "suffix=${{ contains(steps.version_get.outputs.value_old,'-') && '.' || '-' }}" >> $GITHUB_OUTPUT
id: semver-suffix

- name: ✍🏼 version ${{ steps.extract_project.outputs.name }}
id: version_set
uses: endaft/[email protected]
with:
file: ./sambanas/config.yaml
file: ./${{ steps.extract_project.outputs.name }}/config.yaml
path: version
set: .dev${{ github.run_number }}
set: ${{ steps.semver-suffix.outputs.suffix }}dev${{ github.run_number }}
get: true
append: true


- name: Publish SambaNAS Addon ${{ steps.version_set.outputs.value_old }}
- name: 📰 Publish ${{ steps.extract_project.outputs.name }} Addon ${{ steps.version_set.outputs.value_old }}
uses: home-assistant/builder@master
env:
CAS_API_KEY: ${{ secrets.CAS_API_KEY }}
with:
args: |
--aarch64 \
--target sambanas \
--target ${{ steps.extract_project.outputs.name }} \
--docker-hub dianlight
- name: Extract branch name
shell: bash
run: echo "BR_VERSION=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT"
id: extract_branch

- name: pull-request
- name: 🧑🏽‍💻 pull-request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "Prerelease Bot"
git branch -f "prerelease/${{ steps.extract_branch.outputs.BR_VERSION }}_${{ steps.version_set.outputs.value_old }}" HEAD
git push -u origin "prerelease/${{ steps.extract_branch.outputs.BR_VERSION }}_${{ steps.version_set.outputs.value_old }}" || :
git branch -f "prerelease/${{ steps.extract_project.outputs.name }}_${{ steps.version_set.outputs.value_old }}" HEAD
git push -u origin "prerelease/${{ steps.extract_project.outputs.name }}_${{ steps.version_set.outputs.value_old }}" || :
git restore .
git clean -f
gh pr create --base "prerelease/${{ steps.extract_branch.outputs.BR_VERSION }}_${{ steps.version_set.outputs.value_old }}" --title "Releasing ${{ github.ref }} into prerelease" --body ":crown: *An automated PR*"
gh pr create --base "prerelease/${{ steps.extract_project.outputs.name }}_${{ steps.version_set.outputs.value_old }}" --title "Releasing ${{ github.ref }} into prerelease" --body ":crown: *An automated PR*"
37 changes: 29 additions & 8 deletions .github/workflows/docker-image-pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,55 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: ✍🏼 version SambaNAs
- name: 📽️ Extract dev branch project name
shell: bash
run: |
FULL_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/devrelease/}}"
echo "full_name=${FULL_NAME} >> $GITHUB_OUTPUT
echo "name=${FULL_NAME%%_*}" >> $GITHUB_OUTPUT
id: extract_project

- name: ✍🏼 version ${{ steps.extract_project.outputs.name }}
id: version_get
uses: endaft/[email protected]
with:
file: ./${{ steps.extract_project.outputs.name }}/config.yaml
path: version
get: true

- name: 📽️ Identify SemVer ${{ steps.version_get.outputs.value_old }} suffix
shell: bash
run: echo "suffix=${{ contains(steps.version_get.outputs.value_old,'-') && '.' || '-' }}" >> $GITHUB_OUTPUT
id: semver-suffix

- name: ✍🏼 version ${{ steps.extract_project.outputs.name }}
id: version_set
uses: endaft/[email protected]
with:
file: ./sambanas/config.yaml
file: ./${{ steps.extract_project.outputs.name }}/config.yaml
path: version
set: .beta${{ github.run_number }}
set: ${{ steps.semver-suffix.outputs.suffix }}beta${{ github.run_number }}
get: true
append: true

- name: ✍🏼 BetaName SambaNAs
- name: ✍🏼 BetaName ${{ steps.extract_project.outputs.name }}
id: betaname_set
uses: endaft/[email protected]
with:
file: ./sambanas/config.yaml
file: ./${{ steps.extract_project.outputs.name }}/config.yaml
path: name
set:
get: true
append: true

- name: Publish SambaNAS Addon ${{ steps.version_set.outputs.value_new }}
- name: Publish ${{ steps.extract_project.outputs.name }} Addon ${{ steps.version_set.outputs.value_new }}
uses: home-assistant/builder@master
env:
CAS_API_KEY: ${{ secrets.CAS_API_KEY }}
with:
args: |
--all \
--target sambanas \
--target ${{ steps.extract_project.outputs.name }} \
--docker-hub dianlight
- name: Create pull request for Beta Repository
Expand All @@ -63,7 +84,7 @@ jobs:
git_config_user_email: '[email protected]'
git_config_user_name: 'ffp-bot'
target_repo: 'dianlight/hassio-addons-beta'
source_dir: 'sambanas'
source_dir: '${{ steps.extract_project.outputs.name }}'
# source_dir_copy_glob: '!(*.yaml)'
target_dir: ''
pr_target_repo_base_branch: 'master'
Expand Down
53 changes: 0 additions & 53 deletions .github/workflows/docker-image.yml

This file was deleted.

12 changes: 11 additions & 1 deletion .github/workflows/rebuild.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rebuild Docker Image CI
name: Rebuild Docker Image CI - Emergency Rebuild All

on:
workflow_dispatch:
Expand Down Expand Up @@ -27,3 +27,13 @@ jobs:
--all \
--target sambanas \
--docker-hub dianlight
- name: Publish BeSIM Addon
uses: home-assistant/builder@master
env:
CAS_API_KEY: ${{ secrets.CAS_API_KEY }}
with:
args: |
--all \
--target besim \
--docker-hub dianlight

0 comments on commit 2e73f1d

Please sign in to comment.