项目作者: shrink

项目描述 :
:octocat: Extract file(s) from a Docker Image
高级语言: JavaScript
项目地址: git://github.com/shrink/actions-docker-extract.git
创建时间: 2020-08-29T15:15:14Z
项目社区:https://github.com/shrink/actions-docker-extract

开源协议:MIT License

下载


Docker Extract

A GitHub Action for extracting files from a Docker Image.

  1. - uses: shrink/actions-docker-extract@v3
  2. with:
  3. image: "ghost:alpine"
  4. path: "/var/lib/ghost/current/core/built/assets/."

:warning: Due to a breaking change in v3 of GitHub’s actions/upload-artifact, a
low-impact breaking change has been made to v3.0.1 of this action. Please
see issues#28 for
context and support.

Inputs

ID Description Required Examples
image Docker Image to extract files from alpine ghcr.io/github/super-linter:latest
path Path (from root) to a file or directory within Image files/example.txt files files/.
destination Destination path for the extracted files /foo/ ~/ ./foo/bar

:paperclip: To copy the contents of a directory the path must end with
/. otherwise the directory itself will be copied. More information about the
specific rules can be found via the docker cp documentation.

Outputs

ID Description Example
destination Destination path containing the extracted file(s) extracted-1598717412/

Examples

Build, Extract

Using docker/build-push-action to build a Docker
Image and then extract the contents of the /app directory within the newly
built image to upload as a dist artifact.

  1. jobs:
  2. build:
  3. runs-on: ubuntu-latest
  4. steps:
  5. - uses: actions/checkout@v4
  6. - name: Build Docker Image
  7. uses: docker/build-push-action@v5
  8. with:
  9. tags: my-example-image:latest
  10. load: true
  11. - uses: shrink/actions-docker-extract@v3
  12. id: extract
  13. with:
  14. image: my-example-image:latest
  15. path: /app/.
  16. destination: dist
  17. - name: Upload Dist
  18. uses: actions/upload-artifact@v3
  19. with:
  20. path: dist

Login, Pull, Extract

Using docker/login-action to authenticate with the GitHub
Container Registry to extract from a published Docker Image.

  1. jobs:
  2. extract:
  3. runs-on: ubuntu-latest
  4. steps:
  5. - uses: actions/checkout@v4
  6. - name: Login to GitHub Container Registry
  7. uses: docker/login-action@v2
  8. with:
  9. registry: "ghcr.io"
  10. username: "${{ github.actor }}"
  11. password: "${{ secrets.GITHUB_TOKEN }}"
  12. - uses: shrink/actions-docker-extract@v3
  13. id: extract
  14. with:
  15. image: ghcr.io/${{ github.repository }}:latest
  16. path: /app/.
  17. destination: dist
  18. - name: Upload Dist
  19. uses: actions/upload-artifact@v3
  20. with:
  21. path: dist

Automatic Release Packaging

A Workflow packages the Action automatically when a collaborator created a new
tag. Any reference to this Action in a Workflow must use a tag (mutable)
or the commit hash of a tag (immutable).

  1. uses: shrink/actions-docker-extract@v3
  2. uses: shrink/actions-docker-extract@v3.0.0
  3. uses: shrink/actions-docker-extract@40400b42f4f8b663c647f535e2c6674658e39fc6
  4. uses: shrink/actions-docker-extract@main

The blog post
Package GitHub Actions automatically with GitHub Actions
describes how this is achieved.