Assets for Package GitHub Actions automatically with GitHub Actions.
Last active
July 19, 2021 22:29
-
-
Save shrink/ee61ae3e26b2b751178a1cbe673a4cc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- uses: actions/checkout@v2 | |
with: | |
ssh-key: "${{ secrets.COMMIT_KEY }}" |
dev:~$ ssh-keygen -t ed25519 -f id_ed25519 -N "" -q -C ""
dev:~$ cat id_ed25519.pub id_ed25519
ssh-ed25519 ...
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Test Action" | |
on: | |
push: | |
branches: | |
- "**" | |
jobs: | |
test-unit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: npm install | |
- name: Execute unit tests | |
run: npm run all | |
test-integration: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: npm install | |
- name: Package action for integration tests | |
if: ${{ startsWith(github.ref, 'refs/heads/release') }} | |
run: npm run package | |
- id: default | |
uses: ./ | |
- name: Test actor is greeted by default | |
uses: pr-mpt/actions-assert@v2 | |
with: | |
assertion: npm://@assertions/is-equal | |
expected: "Hello, ${{ github.actor }}!" | |
actual: "${{ steps.default.outputs.greeting }}" | |
- ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment