-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (89 loc) · 2.93 KB
/
copy-config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: build and deploy
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: shellcheck
run: shellcheck telegraf/run.sh
- name: Get current Version
id: version
run: |
if [[ "${{ github.ref_type }}" = "tag" ]]; then
echo "version=$(echo ${{ github.ref }} | sed "s/^.*\/v//g")" >> $GITHUB_OUTPUT
else
echo "Ref Type not tag: ${{github.ref_type}}"
echo "latest" >> $GITHUB_OUTPUT
fi
- name: Update Version in build.yml
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
sed -i "s/io.hass.version:.*/io.hass.version: ${VERSION}/g" telegraf/build.yml
sed -i "s/version:.*/version: ${VERSION}/g" telegraf/config.yml
- name: check build.yml and config.yml
run: |
cat telegraf/build.yml | grep "io.hass.version"
cat telegraf/config.yml | grep "version"
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build docker files
uses: home-assistant/[email protected]
with:
args: |
--all \
--target telegraf \
--docker-hub ghcr.io/${{ github.repository_owner }}
push-config-to-addon-repo:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Main Repo
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
path: main
- name: Update Version in config.yml
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
sed -i "s/version:.*/version: ${VERSION}/g" main/telegraf/config.yml
- name: Checkout Addon Repo
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
path: addon
repository: jnull/hassio-addons
- name: setup local env
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
\cp -Rv main/telegraf/config.yml addon/telegraf/config.yml
\cp -Rv main/README.md addon/telegraf/README.md
cd addon
git config --local user.email "[email protected]"
git config --local user.name "jnull"
git add .
git commit -m "Add changes for version: ${VERSION}"
continue-on-error: true
- name: copy config to repo dir in case of change
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.REGISTRY_CREDS }}
repository: jnull/hassio-addons
directory: addon