From a1fc5cb99eb1aca6c16b5979fedfd34acc59bed2 Mon Sep 17 00:00:00 2001 From: NL-TCH Date: Fri, 3 May 2024 22:59:09 +0200 Subject: [PATCH 1/5] rewrite GH actions --- .../workflows/build+push_docker_image .yml | 33 +++++++++ .github/workflows/build_docker_image.yml | 71 +------------------ 2 files changed, 35 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/build+push_docker_image .yml diff --git a/.github/workflows/build+push_docker_image .yml b/.github/workflows/build+push_docker_image .yml new file mode 100644 index 0000000..5405150 --- /dev/null +++ b/.github/workflows/build+push_docker_image .yml @@ -0,0 +1,33 @@ +name: Build docker images + +on: + push: + branches: [ 'master' ] + pull_request: + branches: [ 'master' ] + schedule: + - cron: "0 0 * * 0" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout code from Git repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker login to GitHub + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push the image + run: | + docker buildx build --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . --tag ghcr.io/RaspAP/raspap-docker:latest --tag ghcr.io/RaspAP/raspap-docker:${{ github.run_number }} + docker push ghcr.io/RaspAP/raspap-docker --all-tags \ No newline at end of file diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index 34a62f1..86c58eb 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -3,14 +3,6 @@ name: Build docker images on: push: branches: [ 'master' ] - schedule: - # Cron execution is for weekly dependencies update (for security update) - # ┌───────────── minute (0 - 59) - # │ ┌───────────── hour (0 - 23) - # │ │ ┌───────────── day of the month (1 - 31) - # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) - # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) - - cron: "0 0 * * 0" jobs: build: @@ -20,20 +12,10 @@ jobs: - name: Checkout code from Git repository uses: actions/checkout@v2 - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 - # Only if you want the image to be push to docker.io instead of the GitHub Package repository -# - name: Docker login to DockerHub -# uses: docker/login-action@v1 -# with: -# username: ${{ secrets.DOCKER_USERNAME }} -# password: ${{ secrets.DOCKER_PASSWORD }} - - # Comment this if you prefer to use the docker.io image repository | This method can be better because it didn't need any password (use the credentials of the people who commit) - name: Docker login to GitHub uses: docker/login-action@v1 with: @@ -41,55 +23,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Prepare available platforms build - env: # Here you need to test on what platform your docker image can be build. Important one is linux/arm/v7, linux/arm64 and linux/amd64 - requested_platforms: "linux/amd64,linux/arm64,linux/arm/v7" # jrei/systemd-debian:10 support only i386, amd64, arm and arm64 - image: "ghcr.io/${{ github.repository }}:latest" - run: | - # If you use the `requested_platforms` env var, then parse it. - if [ -n "${requested_platforms}" ]; then - # Transform env var into bash array to calculate arrays intersect. That allow us to know the plateform that can work with our image who can be build on current github docker buildx. - IFS=',' read -r -a requested_platforms <<< "${requested_platforms}" - IFS=',' read -r -a available_platforms <<< "${{ steps.buildx.outputs.platforms }}" - # Only got the intersect of two arrays - available_platforms=$(comm -12 <(printf '%s\n' "${requested_platforms[@]}" | LC_ALL=C sort) <(printf '%s\n' "${available_platforms[@]}" | LC_ALL=C sort)) - # Just format the output for the docker commands - requested_platforms="${requested_platforms//' - '/,}" - available_platforms="${available_platforms//' - '/,}" - else - available_platforms="${{ steps.buildx.outputs.platforms }}" - fi - - echo "available_platforms=$available_platforms" - - # Save Available platforms - echo "available_platforms=${available_platforms}" >> $GITHUB_ENV - echo "docker_image=${image,,}" >> $GITHUB_ENV - - # Use cache image for quicker build time. - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - # Use official buildx GitHub Action - - name: Docker build & push - uses: docker/build-push-action@v2 - with: - context: . - push: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new - platforms: ${{ env.available_platforms }} - tags: ${{ env.docker_image }} - - # Save new cache - - name: Move cache + - name: Build the image run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + docker buildx build --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . --tag ghcr.io/RaspAP/raspap-docker:latest --tag ghcr.io/RaspAP/raspap-docker:${{ github.run_number }} \ No newline at end of file From 3b36957b6eaf42ae57e82fd5dd18139ca7f7b192 Mon Sep 17 00:00:00 2001 From: NL-TCH Date: Fri, 3 May 2024 23:04:11 +0200 Subject: [PATCH 2/5] lowercase error fix --- .github/workflows/build+push_docker_image .yml | 4 ++-- .github/workflows/build_docker_image.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build+push_docker_image .yml b/.github/workflows/build+push_docker_image .yml index 5405150..f1bc0b9 100644 --- a/.github/workflows/build+push_docker_image .yml +++ b/.github/workflows/build+push_docker_image .yml @@ -29,5 +29,5 @@ jobs: - name: Build and push the image run: | - docker buildx build --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . --tag ghcr.io/RaspAP/raspap-docker:latest --tag ghcr.io/RaspAP/raspap-docker:${{ github.run_number }} - docker push ghcr.io/RaspAP/raspap-docker --all-tags \ No newline at end of file + docker buildx build --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . --tag ghcr.io/raspap/raspap-docker:latest --tag ghcr.io/raspap/raspap-docker:${{ github.run_number }} + docker push ghcr.io/raspap/raspap-docker --all-tags \ No newline at end of file diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index 86c58eb..d11340e 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -25,4 +25,4 @@ jobs: - name: Build the image run: | - docker buildx build --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . --tag ghcr.io/RaspAP/raspap-docker:latest --tag ghcr.io/RaspAP/raspap-docker:${{ github.run_number }} \ No newline at end of file + docker buildx build --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . --tag ghcr.io/raspap/raspap-docker:latest --tag ghcr.io/raspap/raspap-docker:${{ github.run_number }} \ No newline at end of file From d5fd428dc37f887d02d48024b172006a648aefd7 Mon Sep 17 00:00:00 2001 From: NL-TCH Date: Fri, 3 May 2024 23:08:23 +0200 Subject: [PATCH 3/5] big whoopsie :) --- .github/workflows/build_docker_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index d11340e..1e3495b 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -1,7 +1,7 @@ name: Build docker images on: - push: + pull_request: branches: [ 'master' ] jobs: From 925853fe5857daf3a6c21a20ef4b3d225cba2cd1 Mon Sep 17 00:00:00 2001 From: NL-TCH Date: Fri, 3 May 2024 23:08:45 +0200 Subject: [PATCH 4/5] Whoopsie 2.0 --- .github/workflows/build+push_docker_image .yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build+push_docker_image .yml b/.github/workflows/build+push_docker_image .yml index f1bc0b9..73d8e33 100644 --- a/.github/workflows/build+push_docker_image .yml +++ b/.github/workflows/build+push_docker_image .yml @@ -3,8 +3,6 @@ name: Build docker images on: push: branches: [ 'master' ] - pull_request: - branches: [ 'master' ] schedule: - cron: "0 0 * * 0" From c33c7dd11957e8a80a59ad9e3e1e3c26fce6270e Mon Sep 17 00:00:00 2001 From: NL-TCH Date: Sat, 4 May 2024 01:20:46 +0200 Subject: [PATCH 5/5] change pipeline name --- .github/workflows/build+push_docker_image .yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build+push_docker_image .yml b/.github/workflows/build+push_docker_image .yml index 73d8e33..a582b83 100644 --- a/.github/workflows/build+push_docker_image .yml +++ b/.github/workflows/build+push_docker_image .yml @@ -1,4 +1,4 @@ -name: Build docker images +name: Build+Push docker images on: push: @@ -27,5 +27,6 @@ jobs: - name: Build and push the image run: | - docker buildx build --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . --tag ghcr.io/raspap/raspap-docker:latest --tag ghcr.io/raspap/raspap-docker:${{ github.run_number }} - docker push ghcr.io/raspap/raspap-docker --all-tags \ No newline at end of file + docker buildx build --push \ + --platform=linux/arm64,linux/amd64,linux/arm64,linux/arm/v7 . \ + --tag ghcr.io/raspap/raspap-docker:latest --tag ghcr.io/raspap/raspap-docker:${{ github.run_number }} \ No newline at end of file