From fab61be3624d6ff8dbde371e41b1f2c7643711a6 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:00:12 +0100 Subject: [PATCH 1/9] cache docker in build step --- .gitea/workflows/upload-image-dev.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml index fbcde55..0276721 100644 --- a/.gitea/workflows/upload-image-dev.yaml +++ b/.gitea/workflows/upload-image-dev.yaml @@ -1,4 +1,4 @@ -Actions name: Publish Docker Image +Actions name: Publish Docker Image (Development) on: push: branches: @@ -11,7 +11,14 @@ jobs: - name: Checkout uses: https://github.com/actions/checkout@v3 - - name: Download Docker + - uses: actions/cache@v3 + id: docker-cache + with: + path: /usr/bin/docker + key: ${{ runner.os }}-${{ hashFiles('**') }} + + - name: Install Docker + if: steps.docker-cache.outputs.cache-hit != 'true' run: | wget -q -O /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-20.10.23.tgz \ && tar --extract --file /tmp/docker.tgz --directory /usr/bin --strip-components 1 --no-same-owner docker/docker \ @@ -31,4 +38,4 @@ jobs: with: push: true context: . - tags: fascinated/sharex-php-uploader:development + tags: fascinated/sharex-php-uploader:latest -- 2.45.2 From 59e116c19d1c35a6db319b65aecbe6d07a84e722 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:01:21 +0100 Subject: [PATCH 2/9] fix key? --- .gitea/workflows/upload-image-dev.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml index 0276721..aa9b9d2 100644 --- a/.gitea/workflows/upload-image-dev.yaml +++ b/.gitea/workflows/upload-image-dev.yaml @@ -11,11 +11,12 @@ jobs: - name: Checkout uses: https://github.com/actions/checkout@v3 - - uses: actions/cache@v3 + - name: Cache Docker + uses: actions/cache@v3 id: docker-cache with: path: /usr/bin/docker - key: ${{ runner.os }}-${{ hashFiles('**') }} + key: ${{ runner.os }}-docker - name: Install Docker if: steps.docker-cache.outputs.cache-hit != 'true' -- 2.45.2 From e2b2d0694b7eec56176effd0de0854014e9159bd Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:02:19 +0100 Subject: [PATCH 3/9] test cache --- .gitea/workflows/upload-image-dev.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml index aa9b9d2..0fc41b4 100644 --- a/.gitea/workflows/upload-image-dev.yaml +++ b/.gitea/workflows/upload-image-dev.yaml @@ -18,12 +18,13 @@ jobs: path: /usr/bin/docker key: ${{ runner.os }}-docker - - name: Install Docker + - name: Install Docker (if not cached) if: steps.docker-cache.outputs.cache-hit != 'true' run: | wget -q -O /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-20.10.23.tgz \ && tar --extract --file /tmp/docker.tgz --directory /usr/bin --strip-components 1 --no-same-owner docker/docker \ - && rm -rf /tmp/* + && rm -rf /tmp/* && + echo "Done" - name: Set up Docker Buildx uses: https://github.com/docker/setup-buildx-action@v2 -- 2.45.2 From 76e6e045b9d0f51f273af0441e466433b95164f3 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:03:38 +0100 Subject: [PATCH 4/9] john made this, i don't expect it to work --- .gitea/workflows/upload-image-dev.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml index 0fc41b4..10aad66 100644 --- a/.gitea/workflows/upload-image-dev.yaml +++ b/.gitea/workflows/upload-image-dev.yaml @@ -35,6 +35,15 @@ jobs: username: ${{ secrets.REPO_USERNAME }} password: ${{ secrets.REPO_TOKEN }} + - name: Cache Docker Build Steps + uses: actions/cache@v2 + id: docker-build-cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-docker-build-${{ hashFiles('**/Dockerfile') }} + restore-keys: | + ${{ runner.os }}-docker-build- + - name: Build and Push uses: docker/build-push-action@v4 with: -- 2.45.2 From b2c59d1c048ab69a8be101b1f3421bd964c11835 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:05:18 +0100 Subject: [PATCH 5/9] more cache tests --- .gitea/workflows/upload-image-dev.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml index 10aad66..edb2625 100644 --- a/.gitea/workflows/upload-image-dev.yaml +++ b/.gitea/workflows/upload-image-dev.yaml @@ -35,14 +35,13 @@ jobs: username: ${{ secrets.REPO_USERNAME }} password: ${{ secrets.REPO_TOKEN }} - - name: Cache Docker Build Steps - uses: actions/cache@v2 - id: docker-build-cache + - name: Restore Docker Build Cache + uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-docker-build-${{ hashFiles('**/Dockerfile') }} + key: ${{ runner.os }}-buildx restore-keys: | - ${{ runner.os }}-docker-build- + ${{ runner.os }}-buildx - name: Build and Push uses: docker/build-push-action@v4 @@ -50,3 +49,11 @@ jobs: push: true context: . tags: fascinated/sharex-php-uploader:latest + + - name: Save Docker Build Cache + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx + restore-keys: | + ${{ runner.os }}-buildx -- 2.45.2 From 06be77cb487b069d2b5cafe2472eb597cc350e51 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:07:43 +0100 Subject: [PATCH 6/9] more tests --- .gitea/workflows/upload-image-dev.yaml | 28 ++++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml index edb2625..7b5fae7 100644 --- a/.gitea/workflows/upload-image-dev.yaml +++ b/.gitea/workflows/upload-image-dev.yaml @@ -1,4 +1,5 @@ -Actions name: Publish Docker Image (Development) +name: Publish Docker Image (Development) + on: push: branches: @@ -9,7 +10,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: https://github.com/actions/checkout@v3 + uses: actions/checkout@v3 - name: Cache Docker uses: actions/cache@v3 @@ -27,33 +28,34 @@ jobs: echo "Done" - name: Set up Docker Buildx - uses: https://github.com/docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v2 - name: Login to Repo - uses: https://github.com/docker/login-action@v2 + uses: docker/login-action@v2 with: username: ${{ secrets.REPO_USERNAME }} password: ${{ secrets.REPO_TOKEN }} - name: Restore Docker Build Cache uses: actions/cache@v3 + id: build-cache with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx - restore-keys: | - ${{ runner.os }}-buildx - name: Build and Push uses: docker/build-push-action@v4 with: push: true context: . - tags: fascinated/sharex-php-uploader:latest + tags: fascinated/sharex-php-uploader:development + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache - name: Save Docker Build Cache - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx - restore-keys: | - ${{ runner.os }}-buildx + if: steps.build-cache.outputs.cache-hit != 'true' + run: | + mkdir -p /tmp/.buildx-cache + cp -r /tmp/.buildx-cache/. /tmp/.buildx-cache-new + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache -- 2.45.2 From 1d65c929765b3b05012c982eba36ffa0aff199f3 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:08:41 +0100 Subject: [PATCH 7/9] rename step --- .gitea/workflows/upload-image-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml index 7b5fae7..90c9099 100644 --- a/.gitea/workflows/upload-image-dev.yaml +++ b/.gitea/workflows/upload-image-dev.yaml @@ -12,7 +12,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Cache Docker + - name: Restore Docker Cache uses: actions/cache@v3 id: docker-cache with: -- 2.45.2 From 072779d19a0c45fcf866ac6eabe011346d3a5d86 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:11:54 +0100 Subject: [PATCH 8/9] move workflows to one file --- .gitea/workflows/upload-image-dev.yaml | 61 -------------------------- .gitea/workflows/upload-image.yaml | 42 +++++++++++++++--- 2 files changed, 35 insertions(+), 68 deletions(-) delete mode 100644 .gitea/workflows/upload-image-dev.yaml diff --git a/.gitea/workflows/upload-image-dev.yaml b/.gitea/workflows/upload-image-dev.yaml deleted file mode 100644 index 90c9099..0000000 --- a/.gitea/workflows/upload-image-dev.yaml +++ /dev/null @@ -1,61 +0,0 @@ -name: Publish Docker Image (Development) - -on: - push: - branches: - - "development" - -jobs: - docker: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Restore Docker Cache - uses: actions/cache@v3 - id: docker-cache - with: - path: /usr/bin/docker - key: ${{ runner.os }}-docker - - - name: Install Docker (if not cached) - if: steps.docker-cache.outputs.cache-hit != 'true' - run: | - wget -q -O /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-20.10.23.tgz \ - && tar --extract --file /tmp/docker.tgz --directory /usr/bin --strip-components 1 --no-same-owner docker/docker \ - && rm -rf /tmp/* && - echo "Done" - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Repo - uses: docker/login-action@v2 - with: - username: ${{ secrets.REPO_USERNAME }} - password: ${{ secrets.REPO_TOKEN }} - - - name: Restore Docker Build Cache - uses: actions/cache@v3 - id: build-cache - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx - - - name: Build and Push - uses: docker/build-push-action@v4 - with: - push: true - context: . - tags: fascinated/sharex-php-uploader:development - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - - name: Save Docker Build Cache - if: steps.build-cache.outputs.cache-hit != 'true' - run: | - mkdir -p /tmp/.buildx-cache - cp -r /tmp/.buildx-cache/. /tmp/.buildx-cache-new - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.gitea/workflows/upload-image.yaml b/.gitea/workflows/upload-image.yaml index e08765b..df50a1b 100644 --- a/.gitea/workflows/upload-image.yaml +++ b/.gitea/workflows/upload-image.yaml @@ -1,34 +1,62 @@ -Actions name: Publish Docker Image +name: Publish Docker Image + on: push: branches: - "master" + - "development" jobs: docker: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: https://github.com/actions/checkout@v3 + uses: actions/checkout@v3 - - name: Download Docker + - name: Restore Docker Cache + uses: actions/cache@v3 + id: docker-cache + with: + path: /usr/bin/docker + key: ${{ runner.os }}-docker + + - name: Install Docker (if not cached) + if: steps.docker-cache.outputs.cache-hit != 'true' run: | wget -q -O /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-20.10.23.tgz \ && tar --extract --file /tmp/docker.tgz --directory /usr/bin --strip-components 1 --no-same-owner docker/docker \ - && rm -rf /tmp/* + && rm -rf /tmp/* && + echo "Done" - name: Set up Docker Buildx - uses: https://github.com/docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v2 - name: Login to Repo - uses: https://github.com/docker/login-action@v2 + uses: docker/login-action@v2 with: username: ${{ secrets.REPO_USERNAME }} password: ${{ secrets.REPO_TOKEN }} + - name: Restore Docker Build Cache + uses: actions/cache@v3 + id: build-cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx + - name: Build and Push uses: docker/build-push-action@v4 with: push: true context: . - tags: fascinated/sharex-php-uploader:latest + tags: fascinated/sharex-php-uploader:${{ gitea.branch }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Save Docker Build Cache + if: steps.build-cache.outputs.cache-hit != 'true' + run: | + mkdir -p /tmp/.buildx-cache + cp -r /tmp/.buildx-cache/. /tmp/.buildx-cache-new + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache -- 2.45.2 From 5dbfd021538c6fa10fe7fba00bf0ba64cb86f596 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 01:20:14 +0100 Subject: [PATCH 9/9] branch name fix? --- .gitea/workflows/upload-image.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/upload-image.yaml b/.gitea/workflows/upload-image.yaml index df50a1b..a624fe8 100644 --- a/.gitea/workflows/upload-image.yaml +++ b/.gitea/workflows/upload-image.yaml @@ -5,11 +5,20 @@ on: branches: - "master" - "development" + paths-ignore: # Files in here will not trigger a build + - "README.md" + - "sharex.sxcu" + - "LICENSE" + - "docker-compose.yml" jobs: docker: runs-on: ubuntu-20.04 steps: + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v7 + - name: Checkout uses: actions/checkout@v3 @@ -49,7 +58,7 @@ jobs: with: push: true context: . - tags: fascinated/sharex-php-uploader:${{ gitea.branch }} + tags: fascinated/sharex-php-uploader:${{ steps.branch-name.outputs.current_branch }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache -- 2.45.2