From 15c8bf3149ce2be5c23f854eee826d7c3d499114 Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 29 Nov 2023 01:03:52 +0700 Subject: [PATCH] docs: Correct (and test) documented examples (#27) --- .github/tests/Dockerfile | 3 ++ .github/workflows/test-readme.yaml | 63 ++++++++++++++++++++++++++++++ README.md | 22 +++++------ 3 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/test-readme.yaml 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 new file mode 100644 index 0000000..470acc6 --- /dev/null +++ b/.github/workflows/test-readme.yaml @@ -0,0 +1,63 @@ +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: + context: ./.github/tests + tags: my-example-image:latest + load: true + - uses: shrink/actions-docker-extract@v3 + id: extract + with: + image: my-example-image:latest + path: /app/. + destination: dist + - name: Upload Dist + uses: actions/upload-artifact@v3 + with: + path: 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 + 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/. + destination: dist + - name: Upload Dist + uses: actions/upload-artifact@v3 + with: + path: dist 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