From 5520175619bce4dde765f7df5857aa0fdf15be5d Mon Sep 17 00:00:00 2001 From: SebClem Date: Mon, 12 Oct 2020 14:26:45 +0200 Subject: [PATCH] :hammer: Fix CI/CD --- .github/workflows/build_addon.yml | 150 +++++++++++++++--------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/.github/workflows/build_addon.yml b/.github/workflows/build_addon.yml index dfde8d3..f9275ea 100644 --- a/.github/workflows/build_addon.yml +++ b/.github/workflows/build_addon.yml @@ -13,78 +13,78 @@ env: - jobs: - build-armhf: - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - arch: [aarch64, amd64, armv7, i386] - steps: - - - uses: actions/checkout@v2 - - - name: Add Qemu-user-static ${{matrix.arch}} - run: docker run --rm --privileged hassioaddons/qemu-user-static:latest - - - name: Set up Docker Buildx ${{matrix.arch}} - uses: docker/setup-buildx-action@v1 - - - name: Set Version Prod ${{matrix.arch}} - if: github.event_name != 'workflow_dispatch' && github.event_name != 'push' - run: | - version=${GITHUB_REF/refs\/tags\//} - if [ -n "$version" ];then - tmp=$(mktemp) - jq --arg version "$version" '.version=$version' ${{env.TARGET}}/config.json > "$tmp" && mv "$tmp" ${{env.TARGET}}/config.json - fi - echo "version_type=prod" >> $GITHUB_ENV - - name: Set Version Test ${{matrix.arch}} - if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' - run: | - version=dev_${GITHUB_RUN_ID} - if [ -n "$version" ];then - tmp=$(mktemp) - jq --arg version "$version" '.version=$version' ${{env.TARGET}}/config.json > "$tmp" && mv "$tmp" ${{env.TARGET}}/config.json - fi - echo "version_type=dev" >> $GITHUB_ENV - - - - name: Get build option ${{matrix.arch}} - run: | - echo "NAME=$(jq --raw-output '.name // empty' "${{env.TARGET}}/config.json" | sed "s/'//g")" >> $GITHUB_ENV - echo "DESCRIPTION=$(jq --raw-output '.description // empty' "${{env.TARGET}}/config.json" | sed "s/'//g")" >> $GITHUB_ENV - echo "URL=$(jq --raw-output '.url // empty' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV - echo "VERSION=$(jq --raw-output '.version' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV - echo "IMAGE=$(echo "${{env.IMAGE}}" | sed -r "s/\{arch\}/${{matrix.arch}}/g")" >> $GITHUB_ENV - echo "BUILD_FROM=homeassistant/${{matrix.arch}}-base:latest" >> $GITHUB_ENV - - - name: Set Tags ${{matrix.arch}} - run: | - if [ "${{env.version_type}}" != "dev" ]; then - echo "TAGS=${{env.REPOSITORY}}/${{env.IMAGE}}:latest, ${{env.REPOSITORY}}/${{env.IMAGE}}:$(jq --raw-output '.version' "${{env.TARGET}}/config.json")" - else - echo "TAGS=${{env.REPOSITORY}}/${{env.IMAGE}}:dev, $(jq --raw-output '.version' "${{env.TARGET}}/config.json")" - fi - - - name: Debug Env - run: | - echo ${{env.IMAGE}} - echo ${{env.VERSION}} - echo ${{env.TAGS}} - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push ${{matrix.arch}} - uses: docker/build-push-action@v2 - with: - push: true - context: ./${{env.TARGET}} - tags: ${{env.TAGS}} - labels: io.hass.name=${{env.NAME}}, io.hass.description=${{env.DESCRIPTION}}, io.hass.url=${{env.URL}}, io.hass.arch=${{matrix.arch}}, io.hass.version=${{env.VERSION}}, io.hass.type=addon - build-args: BUILD_FROM=${{env.BUILD_FROM}}, BUILD_VERSION=${{env.VERSION}} - file: ./${{env.TARGET}}/Dockerfile \ No newline at end of file +jobs: + build-armhf: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + arch: [aarch64, amd64, armv7, i386] + steps: + + - uses: actions/checkout@v2 + + - name: Add Qemu-user-static ${{matrix.arch}} + run: docker run --rm --privileged hassioaddons/qemu-user-static:latest + + - name: Set up Docker Buildx ${{matrix.arch}} + uses: docker/setup-buildx-action@v1 + + - name: Set Version Prod ${{matrix.arch}} + if: github.event_name != 'workflow_dispatch' && github.event_name != 'push' + run: | + version=${GITHUB_REF/refs\/tags\//} + if [ -n "$version" ];then + tmp=$(mktemp) + jq --arg version "$version" '.version=$version' ${{env.TARGET}}/config.json > "$tmp" && mv "$tmp" ${{env.TARGET}}/config.json + fi + echo "version_type=prod" >> $GITHUB_ENV + - name: Set Version Test ${{matrix.arch}} + if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' + run: | + version=dev_${GITHUB_RUN_ID} + if [ -n "$version" ];then + tmp=$(mktemp) + jq --arg version "$version" '.version=$version' ${{env.TARGET}}/config.json > "$tmp" && mv "$tmp" ${{env.TARGET}}/config.json + fi + echo "version_type=dev" >> $GITHUB_ENV + + + - name: Get build option ${{matrix.arch}} + run: | + echo "NAME=$(jq --raw-output '.name // empty' "${{env.TARGET}}/config.json" | sed "s/'//g")" >> $GITHUB_ENV + echo "DESCRIPTION=$(jq --raw-output '.description // empty' "${{env.TARGET}}/config.json" | sed "s/'//g")" >> $GITHUB_ENV + echo "URL=$(jq --raw-output '.url // empty' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV + echo "VERSION=$(jq --raw-output '.version' "${{env.TARGET}}/config.json")" >> $GITHUB_ENV + echo "IMAGE=$(echo "${{env.IMAGE}}" | sed -r "s/\{arch\}/${{matrix.arch}}/g")" >> $GITHUB_ENV + echo "BUILD_FROM=homeassistant/${{matrix.arch}}-base:latest" >> $GITHUB_ENV + + - name: Set Tags ${{matrix.arch}} + run: | + if [ "${{env.version_type}}" != "dev" ]; then + echo "TAGS=${{env.REPOSITORY}}/${{env.IMAGE}}:latest, ${{env.REPOSITORY}}/${{env.IMAGE}}:$(jq --raw-output '.version' "${{env.TARGET}}/config.json")" + else + echo "TAGS=${{env.REPOSITORY}}/${{env.IMAGE}}:dev, $(jq --raw-output '.version' "${{env.TARGET}}/config.json")" + fi + + - name: Debug Env + run: | + echo ${{env.IMAGE}} + echo ${{env.VERSION}} + echo ${{env.TAGS}} + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push ${{matrix.arch}} + uses: docker/build-push-action@v2 + with: + push: true + context: ./${{env.TARGET}} + tags: ${{env.TAGS}} + labels: io.hass.name=${{env.NAME}}, io.hass.description=${{env.DESCRIPTION}}, io.hass.url=${{env.URL}}, io.hass.arch=${{matrix.arch}}, io.hass.version=${{env.VERSION}}, io.hass.type=addon + build-args: BUILD_FROM=${{env.BUILD_FROM}}, BUILD_VERSION=${{env.VERSION}} + file: ./${{env.TARGET}}/Dockerfile \ No newline at end of file