This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
Bump docker/setup-qemu-action from 2 to 3 #159
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Teslamate CI/CD | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '**' | |
- '!**.md' | |
- '!.github/**' | |
release: | |
types: [published] | |
pull_request: | |
paths: | |
- '**' | |
- '!**.md' | |
env: | |
DOCKER_USERNAME: mattffffff | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [amd64, armhf, armv7, aarch64] | |
fail-fast: true | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
- name: Set TESLAMATE_TAG | |
run: | | |
echo "TESLAMATE_TAG=$(jq -r '.args.TESLAMATE_TAG ' < build.json)" >> $GITHUB_ENV | |
- name: Docker version | |
run: docker version | |
- name: Setup qemu | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Install buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
version: latest | |
- name: Available platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: Set PLATFORM & ARCH variables | |
run: | | |
case "${{ matrix.arch }}" in | |
"amd64" ) | |
echo "PLATFORM=linux/amd64" >> $GITHUB_ENV | |
echo "ARCH=amd64" >> $GITHUB_ENV | |
;; | |
"aarch64" ) | |
echo "PLATFORM=linux/arm64" >> $GITHUB_ENV | |
echo "ARCH=aarch64" >> $GITHUB_ENV | |
;; | |
"armhf" ) | |
echo "PLATFORM=linux/arm/v7" >> $GITHUB_ENV | |
echo "ARCH=armhf" >> $GITHUB_ENV | |
;; | |
"armv7" ) | |
echo "PLATFORM=linux/arm/v7" >> $GITHUB_ENV | |
echo "ARCH=arm" >> $GITHUB_ENV | |
;; | |
esac | |
- name: Update config.json if release | |
run: | | |
export RELEASE=$( echo $GITHUB_REF | cut -d/ -f3 | sed s/v// ) | |
jq ".version=\"$RELEASE\"" < config.json > config_release.json | |
rm config.json && mv config_release.json config.json | |
if: ${{ github.event_name == 'release' }} | |
- name: Set environment variables from config.json | |
run: | | |
echo "ADDON_VERSION=$(jq -r .version < config.json)" >> $GITHUB_ENV | |
echo "ADDON_NAME=$(jq -r .name < config.json)" >> $GITHUB_ENV | |
echo "ADDON_DESCRIPTION=$(jq -r .description < config.json)" >> $GITHUB_ENV | |
- name: Login to docker hub | |
run: sudo docker login -u $DOCKER_USERNAME -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Buildx build (if not main) | |
run: | | |
DOCKER_CLI_EXPERIMENTAL=enabled sudo docker buildx build \ | |
--pull \ | |
--platform=$PLATFORM \ | |
--build-arg TESLAMATE_TAG=$TESLAMATE_TAG \ | |
--build-arg ARCH=$ARCH \ | |
--label io.hass.type="addon" \ | |
--label io.hass.name="$ADDON_NAME" \ | |
--label io.hass.description="$ADDON_DESCRIPTION" \ | |
--label io.hass.version="$ADDON_VERSION" \ | |
--label io.hass.arch="${{ matrix.arch }}" \ | |
--label io.hass.url="https://github.com/matt-FFFFFF/hassio-addon-repository/blob/main/teslamate/README.md" \ | |
-t $DOCKER_USERNAME/teslamate-${{ matrix.arch }}:$ADDON_VERSION \ | |
./ | |
if: ${{ github.ref != 'refs/heads/main' }} | |
- name: Buildx build --push (if main or release) | |
run: | | |
DOCKER_CLI_EXPERIMENTAL=enabled sudo docker buildx build \ | |
--pull \ | |
--push \ | |
--platform=$PLATFORM \ | |
--build-arg TESLAMATE_TAG=$TESLAMATE_TAG \ | |
--build-arg ARCH=$ARCH \ | |
--label io.hass.type="addon" \ | |
--label io.hass.name="$ADDON_NAME" \ | |
--label io.hass.description="$ADDON_DESCRIPTION" \ | |
--label io.hass.version="$ADDON_VERSION" \ | |
--label io.hass.arch="${{ matrix.arch }}" \ | |
--label io.hass.url="https://github.com/matt-FFFFFF/hassio-addon-repository/blob/main/teslamate/README.md" \ | |
-t $DOCKER_USERNAME/teslamate-${{ matrix.arch }}:$ADDON_VERSION \ | |
./ | |
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }} |