ci: Package action automatically on release branch (#15)

This commit is contained in:
Samuel Ryan 2022-12-02 16:37:11 +00:00 committed by GitHub
parent abde1147dd
commit 917745b929
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 161 additions and 1623 deletions

19
.github/workflows/build_action.yaml vendored Normal file
View 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 }}

View file

@ -3,11 +3,20 @@ name: Test Directory Extraction
on: [push]
jobs:
action:
uses: ./.github/workflows/build_action.yaml
root-directory:
runs-on: ubuntu-latest
needs:
- action
name: Extract Contents of Directory from Example Image
steps:
- 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
- uses: ./
id: extract
@ -22,9 +31,16 @@ jobs:
- run: test -e ${{ steps.extract.outputs.destination }}/y/006.txt || exit 1
nested-directory:
runs-on: ubuntu-latest
needs:
- action
name: Extract Nested Directory from Example Image
steps:
- 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
- uses: ./
id: extract
@ -35,9 +51,16 @@ jobs:
- run: test -e ${{ steps.extract.outputs.destination }}/x/005.txt || exit 1
nested-directory-contents:
runs-on: ubuntu-latest
needs:
- action
name: Extract Nested Contents of Directory from Example Image
steps:
- 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
- uses: ./
id: extract

View file

@ -3,11 +3,20 @@ name: Test File Extraction
on: [push]
jobs:
action:
uses: ./.github/workflows/build_action.yaml
root-file:
runs-on: ubuntu-latest
needs:
- action
name: Extract Example File From Root of Built Image
steps:
- 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
- uses: ./
id: extract
@ -17,9 +26,16 @@ jobs:
- run: test -e ${{ steps.extract.outputs.destination }}/001.txt || exit 1
nested-file:
runs-on: ubuntu-latest
needs:
- action
name: Extract Nexted Example File From Built Image
steps:
- 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
- uses: ./
id: extract

35
.github/workflows/package-action.yaml vendored Normal file
View 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"

View file

@ -3,11 +3,20 @@ name: Test Cross Platform Support
on: [push]
jobs:
action:
uses: ./.github/workflows/build_action.yaml
linux:
runs-on: ubuntu-latest
needs:
- action
name: Extract Example File on Ubuntu
steps:
- 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
- uses: ./
id: extract
@ -17,9 +26,16 @@ jobs:
- run: test -e ${{ steps.extract.outputs.destination }}/001.txt || exit 1
macos:
runs-on: macos-latest
needs:
- action
name: Extract Example File on macOS
steps:
- uses: actions/checkout@v2
- name: Load action build from cache
uses: actions/cache@v3
with:
path: dist
key: build-${{ github.sha }}
- name: Install Docker
env:
HOMEBREW_GITHUB_API_TOKEN: "${{ github.token }}"

22
.github/workflows/validate-tag.yaml vendored Normal file
View 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