mirror of
https://forgejo.merr.is/annika/actions-docker-extract.git
synced 2025-12-11 13:02:12 -05:00
ci: Package action automatically on release branch (#15)
This commit is contained in:
parent
abde1147dd
commit
917745b929
9 changed files with 161 additions and 1623 deletions
19
.github/workflows/build_action.yaml
vendored
Normal file
19
.github/workflows/build_action.yaml
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
name: "Build Action (if not available)"
|
||||||
|
|
||||||
|
on: [workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-action:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: npm install
|
||||||
|
- name: Build action (if not already built)
|
||||||
|
if: "!startsWith(github.ref, 'refs/heads/release')"
|
||||||
|
run: npm run build
|
||||||
|
- name: Push build into cache
|
||||||
|
if: "!startsWith(github.ref, 'refs/heads/release')"
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
23
.github/workflows/directory.yml
vendored
23
.github/workflows/directory.yml
vendored
|
|
@ -3,11 +3,20 @@ name: Test Directory Extraction
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
action:
|
||||||
|
uses: ./.github/workflows/build_action.yaml
|
||||||
root-directory:
|
root-directory:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- action
|
||||||
name: Extract Contents of Directory from Example Image
|
name: Extract Contents of Directory from Example Image
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Load action build from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
||||||
- uses: ./
|
- uses: ./
|
||||||
id: extract
|
id: extract
|
||||||
|
|
@ -22,9 +31,16 @@ jobs:
|
||||||
- run: test -e ${{ steps.extract.outputs.destination }}/y/006.txt || exit 1
|
- run: test -e ${{ steps.extract.outputs.destination }}/y/006.txt || exit 1
|
||||||
nested-directory:
|
nested-directory:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- action
|
||||||
name: Extract Nested Directory from Example Image
|
name: Extract Nested Directory from Example Image
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Load action build from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
||||||
- uses: ./
|
- uses: ./
|
||||||
id: extract
|
id: extract
|
||||||
|
|
@ -35,9 +51,16 @@ jobs:
|
||||||
- run: test -e ${{ steps.extract.outputs.destination }}/x/005.txt || exit 1
|
- run: test -e ${{ steps.extract.outputs.destination }}/x/005.txt || exit 1
|
||||||
nested-directory-contents:
|
nested-directory-contents:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- action
|
||||||
name: Extract Nested Contents of Directory from Example Image
|
name: Extract Nested Contents of Directory from Example Image
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Load action build from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
||||||
- uses: ./
|
- uses: ./
|
||||||
id: extract
|
id: extract
|
||||||
|
|
|
||||||
16
.github/workflows/file.yml
vendored
16
.github/workflows/file.yml
vendored
|
|
@ -3,11 +3,20 @@ name: Test File Extraction
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
action:
|
||||||
|
uses: ./.github/workflows/build_action.yaml
|
||||||
root-file:
|
root-file:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- action
|
||||||
name: Extract Example File From Root of Built Image
|
name: Extract Example File From Root of Built Image
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Load action build from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
||||||
- uses: ./
|
- uses: ./
|
||||||
id: extract
|
id: extract
|
||||||
|
|
@ -17,9 +26,16 @@ jobs:
|
||||||
- run: test -e ${{ steps.extract.outputs.destination }}/001.txt || exit 1
|
- run: test -e ${{ steps.extract.outputs.destination }}/001.txt || exit 1
|
||||||
nested-file:
|
nested-file:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- action
|
||||||
name: Extract Nexted Example File From Built Image
|
name: Extract Nexted Example File From Built Image
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Load action build from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
||||||
- uses: ./
|
- uses: ./
|
||||||
id: extract
|
id: extract
|
||||||
|
|
|
||||||
35
.github/workflows/package-action.yaml
vendored
Normal file
35
.github/workflows/package-action.yaml
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
name: "Package Action"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "main"
|
||||||
|
|
||||||
|
env:
|
||||||
|
source: "main"
|
||||||
|
release: "release"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
package-changes:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: "${{ env.release }}"
|
||||||
|
fetch-depth: 0
|
||||||
|
ssh-key: "${{ secrets.COMMIT_KEY }}"
|
||||||
|
- uses: pr-mpt/actions-merge-branch@v2
|
||||||
|
with:
|
||||||
|
from: "origin/${{ env.source }}"
|
||||||
|
commit: false
|
||||||
|
- name: Install Javascript dependencies with npm
|
||||||
|
run: npm install
|
||||||
|
- name: Package action for distribution
|
||||||
|
run: npm run package
|
||||||
|
- name: Push packaged action to branch
|
||||||
|
uses: EndBug/add-and-commit@v7
|
||||||
|
with:
|
||||||
|
add: "['.', 'dist --force']"
|
||||||
|
branch: "${{ env.release }}"
|
||||||
|
default_author: github_actions
|
||||||
|
message: "build: Package action as `dist` with latest changes"
|
||||||
16
.github/workflows/platforms.yml
vendored
16
.github/workflows/platforms.yml
vendored
|
|
@ -3,11 +3,20 @@ name: Test Cross Platform Support
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
action:
|
||||||
|
uses: ./.github/workflows/build_action.yaml
|
||||||
linux:
|
linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- action
|
||||||
name: Extract Example File on Ubuntu
|
name: Extract Example File on Ubuntu
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Load action build from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
- run: docker build -t example:${{ github.sha }} ./.github/tests
|
||||||
- uses: ./
|
- uses: ./
|
||||||
id: extract
|
id: extract
|
||||||
|
|
@ -17,9 +26,16 @@ jobs:
|
||||||
- run: test -e ${{ steps.extract.outputs.destination }}/001.txt || exit 1
|
- run: test -e ${{ steps.extract.outputs.destination }}/001.txt || exit 1
|
||||||
macos:
|
macos:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
needs:
|
||||||
|
- action
|
||||||
name: Extract Example File on macOS
|
name: Extract Example File on macOS
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Load action build from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
key: build-${{ github.sha }}
|
||||||
- name: Install Docker
|
- name: Install Docker
|
||||||
env:
|
env:
|
||||||
HOMEBREW_GITHUB_API_TOKEN: "${{ github.token }}"
|
HOMEBREW_GITHUB_API_TOKEN: "${{ github.token }}"
|
||||||
|
|
|
||||||
22
.github/workflows/validate-tag.yaml
vendored
Normal file
22
.github/workflows/validate-tag.yaml
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
name: "Limit Tags To Distributable Commits"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate-tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ssh-key: "${{ secrets.COMMIT_KEY }}"
|
||||||
|
- name: Test that the tagged commit includes `dist`
|
||||||
|
uses: pr-mpt/actions-assert@v2
|
||||||
|
with:
|
||||||
|
assertion: npm://@assertions/directory-exists
|
||||||
|
expected: dist
|
||||||
|
- if: failure()
|
||||||
|
name: Delete invalid tag
|
||||||
|
uses: pr-mpt/actions-delete-tag@v1
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
|
/dist/
|
||||||
|
|
|
||||||
39
README.md
39
README.md
|
|
@ -5,27 +5,27 @@ A GitHub Action for extracting files from a Docker Image.
|
||||||
```yaml
|
```yaml
|
||||||
- uses: shrink/actions-docker-extract@v1
|
- uses: shrink/actions-docker-extract@v1
|
||||||
with:
|
with:
|
||||||
image: 'ghost:alpine'
|
image: "ghost:alpine"
|
||||||
path: '/var/lib/ghost/current/core/built/assets/.'
|
path: "/var/lib/ghost/current/core/built/assets/."
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
All inputs are required.
|
All inputs are required.
|
||||||
|
|
||||||
| ID | Description | Examples |
|
| ID | Description | Examples |
|
||||||
| --- | ----------- | -------- |
|
| ------- | ---------------------------------------------------- | --------------------------------------------- |
|
||||||
| `image` | Docker Image to extract files from | `alpine` `ghcr.io/github/super-linter:latest` |
|
| `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/.` |
|
| `path` | Path (from root) to a file or directory within Image | `files/example.txt` `files` `files/.` |
|
||||||
|
|
||||||
> :paperclip: To copy the **contents** of a directory the `path` must end with
|
> :paperclip: To copy the **contents** of a directory the `path` must end with
|
||||||
`/.` otherwise the directory itself will be copied. More information about the
|
> `/.` otherwise the directory itself will be copied. More information about the
|
||||||
specific rules can be found via the [docker cp][docker-cp] documentation.
|
> specific rules can be found via the [docker cp][docker-cp] documentation.
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
| ID | Description | Example |
|
| ID | Description | Example |
|
||||||
| --- | ----------- | ------- |
|
| ------------- | ------------------------------------------------- | ------------------------ |
|
||||||
| `destination` | Destination path containing the extracted file(s) | `.extracted-1598717412/` |
|
| `destination` | Destination path containing the extracted file(s) | `.extracted-1598717412/` |
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
@ -88,6 +88,25 @@ jobs:
|
||||||
name: dist
|
name: 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][tags] (mutable)
|
||||||
|
or the commit hash of a tag (immutable).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
✅ uses: shrink/actions-docker-extract@v2
|
||||||
|
✅ uses: shrink/actions-docker-extract@v2.0.0
|
||||||
|
✅ uses: shrink/actions-docker-extract@abde1147dd0d248b38feda9e75768c3d2b57eefc
|
||||||
|
❌ uses: shrink/actions-docker-extract@main
|
||||||
|
```
|
||||||
|
|
||||||
|
The blog post
|
||||||
|
[Package GitHub Actions automatically with GitHub Actions][blog/package-automatically]
|
||||||
|
describes how this is achieved.
|
||||||
|
|
||||||
[build-push-action]: https://github.com/docker/build-push-action
|
[build-push-action]: https://github.com/docker/build-push-action
|
||||||
[login-action]: https://github.com/docker/login-action
|
[login-action]: https://github.com/docker/login-action
|
||||||
[docker-cp]: https://docs.docker.com/engine/reference/commandline/cp/#extended-description
|
[docker-cp]: https://docs.docker.com/engine/reference/commandline/cp/#extended-description
|
||||||
|
[tags]: https://github.com/shrink/actions-docker-extract/tags
|
||||||
|
[blog/package-automatically]: https://medium.com/prompt/package-github-actions-automatically-with-github-actions-a70b9f7bae4
|
||||||
|
|
|
||||||
1613
dist/index.js
vendored
1613
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue