From e514eda57415285baa4ec5c65d296d13cfdf665a Mon Sep 17 00:00:00 2001 From: Jason N <33561705+JasonN3@users.noreply.github.com> Date: Tue, 26 Mar 2024 20:41:20 -0400 Subject: [PATCH 1/5] fix badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e8611f..f386545 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Build status](https://github.com/jasonn3/build-container-installer/actions/workflows/build-and-test.yml/badge.svg?event=push) +![Build status](https://github.com/jasonn3/build-container-installer/actions/workflows/tests.yml/badge.svg?event=push) # Build Container Installer Action This action is used to enerate an ISO for installing an OSTree stored in a container image. This utilizes the anaconda command `ostreecontainer` From 41e2ae1242c3ae106f01fb6e5ff0d4788d027e1e Mon Sep 17 00:00:00 2001 From: Jason N <33561705+JasonN3@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:06:16 -0400 Subject: [PATCH 2/5] Fix version tag (#90) --- .github/workflows/build_container.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_container.yml b/.github/workflows/build_container.yml index 23966d1..174d39b 100644 --- a/.github/workflows/build_container.yml +++ b/.github/workflows/build_container.yml @@ -69,8 +69,9 @@ jobs: tags: | type=ref,event=branch type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{major}}.{{minor}}.{{patch}} - name: Docker meta for PR if: inputs.pr From 5d818dc7f1ab24b6f3c24a68ec06290941c2b51a Mon Sep 17 00:00:00 2001 From: Jason N <33561705+JasonN3@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:31:20 -0400 Subject: [PATCH 3/5] Delete untagged packages (#91) --- .github/workflows/clean_repo.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/clean_repo.yml diff --git a/.github/workflows/clean_repo.yml b/.github/workflows/clean_repo.yml new file mode 100644 index 0000000..cd84fec --- /dev/null +++ b/.github/workflows/clean_repo.yml @@ -0,0 +1,19 @@ +on: + #schedule: + # - cron: '39 21 * * *' + + workflow_dispatch: + +jobs: + build-container: + name: Delete untagged packages + runs-on: ubuntu-latest + steps: + - name: Dlete Untagged packages + uses: Chizkiyahu/delete-untagged-ghcr-action@v3 + with: + token: ${{ secrets.PACKAGE_DELETER }} + repository_owner: ${{ github.repository_owner }} + repository: ${{ github.repository }} + untagged_only: true + owner_type: user \ No newline at end of file From 7311a1d4c8716f329419a97cdb4148169cfcb2d2 Mon Sep 17 00:00:00 2001 From: Jason N <33561705+JasonN3@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:02:56 -0400 Subject: [PATCH 4/5] Clean repo of old packages (#92) --- .github/workflows/clean_repo.yml | 144 ++++++++++++++++++++++++++++--- .github/workflows/stale.yml | 2 +- 2 files changed, 135 insertions(+), 11 deletions(-) diff --git a/.github/workflows/clean_repo.yml b/.github/workflows/clean_repo.yml index cd84fec..7c4de9f 100644 --- a/.github/workflows/clean_repo.yml +++ b/.github/workflows/clean_repo.yml @@ -1,19 +1,143 @@ +name: Clean Container Registry on: - #schedule: - # - cron: '39 21 * * *' + schedule: + - cron: '0 21 * * 0' workflow_dispatch: jobs: - build-container: - name: Delete untagged packages + delete_untagged: + name: Delete Untagged Packages runs-on: ubuntu-latest steps: - - name: Dlete Untagged packages + - name: Delete Untagged Packages uses: Chizkiyahu/delete-untagged-ghcr-action@v3 with: - token: ${{ secrets.PACKAGE_DELETER }} - repository_owner: ${{ github.repository_owner }} - repository: ${{ github.repository }} - untagged_only: true - owner_type: user \ No newline at end of file + token: ${{ secrets.PACKAGE_DELETER }} + repository_owner: ${{ github.repository_owner }} + repository: ${{ github.repository }} + untagged_only: true + owner_type: user + + delete_old_pr: + name: Delete Old PR Packages + runs-on: ubuntu-latest + permissions: + packages: read + steps: + - name: Delete Old PR Packages + id: all_tags + run: | + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ github.token }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/user/packages/container/build-container-installer/versions" > all_packages.json + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ github.token }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/pulls | \ + jq -r '.[] | select(.state == "open") | .number' | \ + sed 's/^/pr-/g' > open_prs + cat << EOF | python + import json + import re + + prs = open("open_prs", "r") + open_prs = prs.readlines() + open_prs = [x.strip() for x in open_prs] + + all_packages = open('all_packages.json') + data = json.load(all_packages) + + delete_versions = open("delete_versions", "w") + + for i in data: + delete = True + for tag in i['metadata']['container']['tags']: + if not re.match('pr-.*', tag): + delete = False + continue + if tag in open_prs: + delete = False + if delete: + print("delete", i['id']) + delete_versions.write(str(i['id'])) + delete_versions.write("\n") + print(i['metadata']['container']['tags']) + EOF + + for id in $(cat delete_versions) + do + curl -L \ + -X DELETE \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.PACKAGE_DELETER }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/user/packages/container/build-container-installer/versions/${id} + done + + + delete_old_branches: + name: Delete Old Branch Packages + runs-on: ubuntu-latest + permissions: + packages: read + steps: + - name: Delete Old Branch Packages + run: | + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ github.token }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/user/packages/container/build-container-installer/versions" > all_packages.json + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ github.token }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/branches | jq -r '.[].name' > branches + + cat << EOF | python + import json + import re + + branches_f = open("branches", "r") + branches = branches_f.readlines() + branches = [x.strip() for x in branches] + + all_packages_f = open('all_packages.json') + data = json.load(all_packages_f) + + delete_versions = open("delete_versions", "w") + + for i in data: + delete = True + for tag in i['metadata']['container']['tags']: + if re.match('v[0-9]+\\\.[0-9]+\\\.[0-9]+', tag): + delete = False + continue + if re.match('pr-.*', tag): + delete = False + continue + if tag in branches: + delete = False + continue + if tag == "latest": + delete = False + if delete: + print("delete", i['id']) + delete_versions.write(str(i['id'])) + delete_versions.write("\n") + print(i['metadata']['container']['tags']) + EOF + + for id in $(cat delete_versions) + do + curl -L \ + -X DELETE \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.PACKAGE_DELETER }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/user/packages/container/build-container-installer/versions/${id} + done diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 6ad1c0a..5606c09 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,7 +7,7 @@ name: Mark stale issues and pull requests on: schedule: - - cron: '39 21 * * *' + - cron: '0 21 * * *' jobs: stale: From bcc5ae23a13c6b851bd7a8ddf2a2cf13d9a29ebf Mon Sep 17 00:00:00 2001 From: Jason N <33561705+JasonN3@users.noreply.github.com> Date: Thu, 28 Mar 2024 20:53:36 -0400 Subject: [PATCH 5/5] Pass Flatpak vars directly and let Makefile figure it out from there (#94) --- .github/workflows/build_iso.yml | 111 ++++++++++++++++++++++++++++++++ action.yml | 12 +--- 2 files changed, 114 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_iso.yml b/.github/workflows/build_iso.yml index 572cdbf..03ef271 100644 --- a/.github/workflows/build_iso.yml +++ b/.github/workflows/build_iso.yml @@ -158,3 +158,114 @@ jobs: context: ${{ env.JOB_NAME }} (${{ matrix.version }}) sha: ${{ env.sha }} targetUrl: ${{ steps.jobs.outputs.html_url }} + + build_iso_no_flatpaks: + name: Build ISO without Flatpaks + env: + JOB_NAME: Build ISO without Flatpaks + runs-on: ubuntu-latest + needs: + - load_vars + permissions: + contents: read + statuses: write + continue-on-error: false + strategy: + fail-fast: false + matrix: + version: + - 38 + - 39 + - 40 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Switch branch + if: inputs.pr + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ github.token }} + run: | + sudo apt-get update + sudo apt-get install -y hub + hub pr checkout ${{ inputs.pr }} + echo "sha=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Get Current Job Log URL + if: inputs.pr && always() + uses: Tiryoh/gha-jobid-action@v1 + id: jobs + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + job_name: "${{ inputs.parent_job_name }} / ${{ env.JOB_NAME }} (${{ matrix.version }})" + + - name: Set status + if: inputs.pr && always() + uses: myrotvorets/set-commit-status-action@v2.0.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: pending + context: ${{ env.JOB_NAME }} (${{ matrix.version }}) + sha: ${{ env.sha }} + targetUrl: ${{ steps.jobs.outputs.html_url }} + + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true + + - name: Lowercase Registry + id: registry_case + uses: ASzc/change-string-case-action@v6 + with: + string: ${{ needs.load_vars.outputs.IMAGE_REPO }} + + - name: Get image version + id: meta + uses: docker/metadata-action@v5 + with: + tags: | + type=ref,event=branch + type=ref,event=pr + + - name: Login to Registry + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build ISO + uses: ./ + id: build + with: + arch: ${{ needs.load_vars.outputs.ARCH }} + image_name: ${{ needs.load_vars.outputs.IMAGE_NAME }} + image_repo: ${{ needs.load_vars.outputs.IMAGE_REPO }} + image_tag: ${{ matrix.version }} + version: ${{ matrix.version }} + variant: ${{ needs.load_vars.outputs.VARIANT }} + secure_boot_key_url: ${{ needs.load_vars.outputs.SECURE_BOOT_KEY_URL }} + enrollment_password: ${{ needs.load_vars.outputs.ENROLLMENT_PASSWORD }} + iso_name: ${{ needs.load_vars.outputs.IMAGE_NAME }}-${{ matrix.version }}.iso + + - name: Set status + if: inputs.pr && always() + uses: myrotvorets/set-commit-status-action@v2.0.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + context: ${{ env.JOB_NAME }} (${{ matrix.version }}) + sha: ${{ env.sha }} + targetUrl: ${{ steps.jobs.outputs.html_url }} diff --git a/action.yml b/action.yml index c856f54..b44a230 100644 --- a/action.yml +++ b/action.yml @@ -135,7 +135,7 @@ runs: mkdir /cache/skopeo || true - name: Determine Flatpak dependencies - if: inputs.enable_flatpak_dependencies == 'true' + if: inputs.enable_flatpak_dependencies == 'true' && (inputs.flatpak_remote_refs != '' || inputs.flatpak_remote_refs_dir != '') id: flatpak_dependencies shell: bash run: | @@ -207,13 +207,6 @@ runs: then echo "ERROR: flatpak_remote_refs is mutually exclusive to flatpak_remote_refs_dir" exit 1 - else - if [[ -n "${{ inputs.flatpak_remote_refs }}" ]] - then - vars="${vars} FLATPAK_REMOTE_REFS=\"${{ inputs.flatpak_remote_refs }}\"" - else - vars="${vars} FLATPAK_REMOTE_REFS_DIR=\"${{ inputs.flatpak_remote_refs_dir }}\"" - fi fi docker run --privileged --volume ${{ github.workspace }}:/github/workspace/ ${cache} ${image}:${tag} \ ADDITIONAL_TEMPLATES="${{ inputs.additional_templates }}" \ @@ -221,7 +214,8 @@ runs: DNF_CACHE="/cache/dnf" \ ENROLLMENT_PASSWORD="${{ inputs.enrollment_password }}" \ FLATPAK_REMOTE_NAME="${{ inputs.flatpak_remote_name }}" \ - ${vars} \ + FLATPAK_REMOTE_REFS="${{ inputs.flatpak_remote_refs }}" \ + FLATPAK_REMOTE_REFS_DIR="${{ inputs.flatpak_remote_refs_dir }}" \ FLATPAK_REMOTE_URL="${{ inputs.flatpak_remote_url }}" \ FLATPAK_DIR="${{ steps.flatpak_dependencies.outputs.flatpak_dir && format('/github/workspace/{0}', steps.flatpak_dependencies.outputs.flatpak_dir) || '' }}" \ IMAGE_NAME="${{ inputs.image_name }}" \