Git Product home page Git Product logo

actions-docker-extract's Introduction

Docker Extract

A GitHub Action for extracting files from a Docker Image.

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

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

📎 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.

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build Docker Image
        uses: docker/build-push-action@v5
        with:
          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

Login, Pull, Extract

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

jobs:
  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/.
          destination: dist
      - name: Upload Dist
        uses: actions/upload-artifact@v3
        with:
          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).

✅ uses: shrink/actions-docker-extract@v3
✅ uses: shrink/[email protected]
✅ uses: shrink/actions-docker-extract@40400b42f4f8b663c647f535e2c6674658e39fc6
❌ uses: shrink/actions-docker-extract@main

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.