From f844da3e332125ec0a59f2a0b0ccb0dba891ebcb Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Tue, 28 Nov 2023 23:12:13 +0700 Subject: [PATCH 1/8] ci: Add test of README example --- .github/workflows/test-readme.yaml | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/test-readme.yaml diff --git a/.github/workflows/test-readme.yaml b/.github/workflows/test-readme.yaml new file mode 100644 index 0000000..149a84e --- /dev/null +++ b/.github/workflows/test-readme.yaml @@ -0,0 +1,44 @@ +name: Test Readme Example + +on: [workflow_dispatch] + +jobs: + build-extract: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build Docker Image + uses: docker/build-push-action@v5 + with: + load: true + tags: my-example-image:latest + - uses: shrink/actions-docker-extract@v3 + id: extract + with: + image: my-example-image:latest + path: /app/. + - name: Upload Dist + uses: actions/upload-artifact@v3 + with: + path: ${{ steps.extract.outputs.destination }} + name: dist + login-pull-extract: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: "ghcr.io" + username: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + - uses: shrink/actions-docker-extract@v3 + id: extract + with: + image: ghcr.io/${{ github.repository }}:latest + path: /app/. + - name: Upload Dist + uses: actions/upload-artifact@v3 + with: + path: ${{ steps.extract.outputs.destination }} + name: dist \ No newline at end of file From 3e0929e8ea24b2d63edaf516acf55cf9a6f88d60 Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Tue, 28 Nov 2023 23:14:07 +0700 Subject: [PATCH 2/8] ci: Run on push --- .github/workflows/test-readme.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-readme.yaml b/.github/workflows/test-readme.yaml index 149a84e..68d870a 100644 --- a/.github/workflows/test-readme.yaml +++ b/.github/workflows/test-readme.yaml @@ -1,6 +1,6 @@ name: Test Readme Example -on: [workflow_dispatch] +on: [workflow_dispatch, push] jobs: build-extract: From 42e10286ebd441e0a43bdd4f20741b9a1dd5a2dd Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Tue, 28 Nov 2023 23:21:56 +0700 Subject: [PATCH 3/8] ci: Build example image --- .github/workflows/test-readme.yaml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-readme.yaml b/.github/workflows/test-readme.yaml index 68d870a..7ae6b6b 100644 --- a/.github/workflows/test-readme.yaml +++ b/.github/workflows/test-readme.yaml @@ -10,6 +10,7 @@ jobs: - name: Build Docker Image uses: docker/build-push-action@v5 with: + context: ./.github/tests load: true tags: my-example-image:latest - uses: shrink/actions-docker-extract@v3 @@ -22,8 +23,26 @@ jobs: with: path: ${{ steps.extract.outputs.destination }} name: dist + example-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: "ghcr.io" + username: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + - name: Build Docker Image + uses: docker/build-push-action@v5 + with: + context: ./.github/tests + push: true + tags: ghcr.io/${{ github.repository }}:latest login-pull-extract: runs-on: ubuntu-latest + needs: + - example-image steps: - uses: actions/checkout@v4 - name: Login to GitHub Container Registry @@ -36,7 +55,7 @@ jobs: id: extract with: image: ghcr.io/${{ github.repository }}:latest - path: /app/. + path: /files/. - name: Upload Dist uses: actions/upload-artifact@v3 with: From 2736f956f6a50b0d7fceeb029357d27ffa9e9046 Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Tue, 28 Nov 2023 23:23:52 +0700 Subject: [PATCH 4/8] ci: Add `app` path to the test image --- .github/tests/Dockerfile | 3 +++ .github/workflows/test-readme.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/tests/Dockerfile b/.github/tests/Dockerfile index a382ede..f64db51 100644 --- a/.github/tests/Dockerfile +++ b/.github/tests/Dockerfile @@ -9,3 +9,6 @@ RUN echo "Hello, World 3! \$(date)" > /files/003.txt RUN echo "Hello, World 4! \$(date)" > /files/x/004.txt RUN echo "Hello, World 5! \$(date)" > /files/x/005.txt RUN echo "Hello, World 6! \$(date)" > /files/y/006.txt + +RUN mkdir -p /app/ +RUN echo "

Hello, World!

" > /app/index.html diff --git a/.github/workflows/test-readme.yaml b/.github/workflows/test-readme.yaml index 7ae6b6b..82b9af5 100644 --- a/.github/workflows/test-readme.yaml +++ b/.github/workflows/test-readme.yaml @@ -55,7 +55,7 @@ jobs: id: extract with: image: ghcr.io/${{ github.repository }}:latest - path: /files/. + path: /app/. - name: Upload Dist uses: actions/upload-artifact@v3 with: From 3fb13394024f855cd7d04bac463449b8a52679f5 Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Tue, 28 Nov 2023 23:26:51 +0700 Subject: [PATCH 5/8] ci: Add destination to example --- .github/workflows/test-readme.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-readme.yaml b/.github/workflows/test-readme.yaml index 82b9af5..416d3cf 100644 --- a/.github/workflows/test-readme.yaml +++ b/.github/workflows/test-readme.yaml @@ -18,11 +18,11 @@ jobs: with: image: my-example-image:latest path: /app/. + destination: dist - name: Upload Dist uses: actions/upload-artifact@v3 with: - path: ${{ steps.extract.outputs.destination }} - name: dist + path: dist example-image: runs-on: ubuntu-latest steps: @@ -59,5 +59,4 @@ jobs: - name: Upload Dist uses: actions/upload-artifact@v3 with: - path: ${{ steps.extract.outputs.destination }} - name: dist \ No newline at end of file + path: dist From 6362e195c98e1e56062ce82deedd94b07727d6a1 Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Tue, 28 Nov 2023 23:31:57 +0700 Subject: [PATCH 6/8] docs(readme): Add corrected and tested examples --- .github/workflows/test-readme.yaml | 3 ++- README.md | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-readme.yaml b/.github/workflows/test-readme.yaml index 416d3cf..3ba38f2 100644 --- a/.github/workflows/test-readme.yaml +++ b/.github/workflows/test-readme.yaml @@ -11,8 +11,8 @@ jobs: uses: docker/build-push-action@v5 with: context: ./.github/tests - load: true tags: my-example-image:latest + load: true - uses: shrink/actions-docker-extract@v3 id: extract with: @@ -56,6 +56,7 @@ jobs: with: image: ghcr.io/${{ github.repository }}:latest path: /app/. + destination: dist - name: Upload Dist uses: actions/upload-artifact@v3 with: diff --git a/README.md b/README.md index 36b5fe0..933deee 100644 --- a/README.md +++ b/README.md @@ -44,18 +44,18 @@ jobs: - name: Build Docker Image uses: docker/build-push-action@v5 with: - repository: my-example-image - tags: latest + tags: my-example-image:latest + load: true - uses: shrink/actions-docker-extract@v3 id: extract with: - image: my-example-image + image: my-example-image:latest path: /app/. + destination: dist - name: Upload Dist uses: actions/upload-artifact@v3 with: - path: ${{ steps.extract.outputs.destination }} - name: dist + path: dist ``` ### Login, Pull, Extract @@ -70,21 +70,21 @@ jobs: steps: - uses: actions/checkout@v4 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_PAT }} + registry: "ghcr.io" + username: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" - uses: shrink/actions-docker-extract@v3 id: extract with: image: ghcr.io/${{ github.repository }}:latest path: /app/. + destination: dist - name: Upload Dist uses: actions/upload-artifact@v3 with: - path: ${{ steps.extract.outputs.destination }} - name: dist + path: dist ``` ## Automatic Release Packaging From 562534b24e733627e01998ef9cd9b7c20980961b Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Wed, 29 Nov 2023 00:09:12 +0700 Subject: [PATCH 7/8] ci: Trigger GitHub Actions From c5faeddf435716ee6ccb6d27cd255c94ab2ea61d Mon Sep 17 00:00:00 2001 From: Samuel Ryan Date: Wed, 29 Nov 2023 00:56:50 +0700 Subject: [PATCH 8/8] ci: Remove trigger on push from README tests --- .github/workflows/test-readme.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-readme.yaml b/.github/workflows/test-readme.yaml index 3ba38f2..470acc6 100644 --- a/.github/workflows/test-readme.yaml +++ b/.github/workflows/test-readme.yaml @@ -1,6 +1,6 @@ name: Test Readme Example -on: [workflow_dispatch, push] +on: [workflow_dispatch] jobs: build-extract: