name: Build addon on: release: types: [published] push: workflow_dispatch: env: TARGET: nextcloud_backup IMAGE: "hassio-nextcloud-backup" REPOSITORY: ghcr.io/sebclem IMAGE_SOURCE: https://github.com/Sebclem/hassio-nextcloud-backup jobs: build-front: name: Build Front runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v4 - name: Enable corepack run: corepack enable - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: "pnpm" cache-dependency-path: nextcloud_backup/frontend/pnpm-lock.yaml - name: Install dependencies run: pnpm i working-directory: nextcloud_backup/frontend - name: Build run: pnpm build working-directory: nextcloud_backup/frontend - name: Upload production-ready build files uses: actions/upload-artifact@v4 with: name: front_dist path: nextcloud_backup/frontend/dist/ build-back: name: Build back runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v4 - name: Enable corepack run: corepack enable - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: "pnpm" cache-dependency-path: nextcloud_backup/backend/pnpm-lock.yaml - name: Install dependencies run: pnpm i working-directory: nextcloud_backup/backend - name: Lint run: pnpm lint working-directory: nextcloud_backup/backend - name: Build run: pnpm build working-directory: nextcloud_backup/backend - name: Upload production-ready build files uses: actions/upload-artifact@v4 with: name: back_dist path: nextcloud_backup/backend/dist/ build-dockers: runs-on: ubuntu-latest needs: - build-back - build-front strategy: fail-fast: false matrix: arch: [ aarch64, amd64, armv7 ] include: - arch: aarch64 arch_value: linux/arm64/v8 - arch: amd64 arch_value: linux/amd64 - arch: armv7 arch_value: linux/arm/v7 steps: - uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx ${{matrix.arch}} uses: docker/setup-buildx-action@v3 - 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 "BUILD_FROM=ghcr.io/home-assistant/${{matrix.arch}}-base:$(cat nextcloud_backup/.base_version)" >> $GITHUB_ENV - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: | ${{env.REPOSITORY}}/${{env.IMAGE}}/${{matrix.arch}} tags: | type=ref,event=branch,suffix=.${{ github.run_number }} type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} labels: | io.hass.name=${{env.NAME}} io.hass.description=${{env.DESCRIPTION}} io.hass.url=${{env.URL}} io.hass.arch=${{matrix.arch}} io.hass.type=addon - name: Debug Env run: | echo "${{ steps.meta.outputs.tags }}" echo "${{ steps.meta.outputs.labels }}" - name: Login to ghcr.io uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push ${{matrix.arch}} uses: docker/build-push-action@v6 with: push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.event_name == 'release') }} tags: ${{ steps.meta.outputs.tags }} labels: | ${{ steps.meta.outputs.labels }} io.hass.version=${{steps.meta.outputs.version}} build-args: | BUILD_FROM=${{env.BUILD_FROM}} file: ./${{env.TARGET}}/Dockerfile cache-from: type=registry,ref=${{env.REPOSITORY}}/${{env.IMAGE}}/${{matrix.arch}}:latest cache-to: type=inline context: ./${{env.TARGET}}/ platforms: ${{ matrix.arch_value }} publish-main: name: Publish main runs-on: ubuntu-latest needs: - build-dockers if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }} steps: - name: Checkout repo uses: actions/checkout@v4 with: path: "addon" - name: Checkout Hass repo uses: actions/checkout@v4 with: repository: Sebclem/sebclem-hassio-addon-repository path: "repository" - name: Get branch names id: branch-names uses: tj-actions/branch-names@v8 - name: Generate readme uses: cuchi/jinja2-action@v1.2.2 with: template: addon/nextcloud_backup/.README.md.j2 output_file: repository/nextcloud_backup/README.md variables: version=${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number}} - name: Move other files run: | cp addon/nextcloud_backup/DOCS.md repository/nextcloud_backup/ cp addon/nextcloud_backup/icon.png repository/nextcloud_backup/ cp addon/nextcloud_backup/logo.png repository/nextcloud_backup/ cp addon/nextcloud_backup/config.yml repository/nextcloud_backup/ - name: Change version in config file uses: fjogeleit/yaml-update-action@main with: valueFile: 'repository/nextcloud_backup/config.yml' propertyPath: 'version' value: ${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number}} commitChange: false - name: Create pull request uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.PAT_PR }} path: "repository" commit-message: "Update Nextcloud Backup to ${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number }}" branch: "update/bextcloud_backup/${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number }}" base: "${{ steps.branch-names.outputs.current_branch }}" title: "Update Nextcloud Backup to ${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number }}"