Skip to content

Commit

Permalink
feat: Use forked gamma releases
Browse files Browse the repository at this point in the history
- Modify action to use forked gamma releases
- Add GH Workflows to test action and check dist
- Bump dependencies to Node v20
  • Loading branch information
vincenthsh committed May 9, 2024
1 parent 82da5fc commit 6f1144c
Show file tree
Hide file tree
Showing 8 changed files with 6,016 additions and 4,155 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check dist

on:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
workflow_dispatch:

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: yarn

- name: Install dependencies
run: yarn install --check-files

- name: Rebuild the dist directory
run: yarn build

- name: Compare the expected and actual dist directories
run: |
if [ "$(git diff --ignore-space-at-eol ./dist | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after the build. See the status below:"
git diff
exit 1
fi
id: diff

# If inners of the dist directory were different than expected, upload the expected version as an artifact
- name: Upload artifact
if: ${{failure() && steps.diff.conclusion == 'failure'}}
uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist
90 changes: 90 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: "build-test"
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main

jobs:
build: # make sure the action builds
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: yarn

- name: Install dependencies
run: yarn install --check-files

- name: Rebuild the dist directory
run: yarn build

test-v1: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use local action
uses: ./
with:
version: "1.2.0"
- name: Validate action output
env:
V1_RELEASE: "1.2.0"
run: |
GAMMA_PATH=$(command -v gamma)
if [ -z "${GAMMA_PATH}" ]; then
echo "Gamma is not in github runner PATH!"
exit 1
fi
INSTALLED_VERSION_FULL=$(gamma --version)
INSTALLED_VERSION=${INSTALLED_VERSION_FULL##* }
if [ "${INSTALLED_VERSION}" != "${V1_RELEASE}" ]; then
echo "Installed version of gamma ($INSTALLED_VERSION) does not match the latest release ($V1_RELEASE)!"
exit 1
fi
echo "Gamma is correctly installed and ${V1_RELEASE}."
test-latest: # make sure the action gets latest when version is not provided
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use local action
uses: ./
- name: Validate action output
run: |
GAMMA_PATH=$(command -v gamma)
if [ -z "${GAMMA_PATH}" ]; then
echo "Gamma is not in github runner PATH!"
exit 1
fi
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/vincenthsh/gamma/releases/latest" | jq -r .tag_name)
if [ -z "${LATEST_RELEASE}" ]; then
echo "Unable to retrieve the latest release of gamma from GitHub!"
exit 1
fi
LATEST_RELEASE=${LATEST_RELEASE#v}
INSTALLED_VERSION_FULL=$(gamma --version)
INSTALLED_VERSION=${INSTALLED_VERSION_FULL##* }
if [ "${INSTALLED_VERSION}" != "${LATEST_RELEASE}" ]; then
echo "Installed version of gamma (${INSTALLED_VERSION}) does not match the latest release (${LATEST_RELEASE})!"
exit 1
fi
echo "Gamma is correctly installed and latest."
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# setup-gamma
# setup-gamma Fork

Setup your GitHub actions workflow with a specific version of Gamma
Setup your GitHub actions workflow with a specific version of Gamma fork.

> [!WARNING]
> This action installs [vincenthsh/gamma](https://github.com/vincenthsh/gamma)
## How to use with GitHub Actions

Expand Down Expand Up @@ -53,13 +56,14 @@ jobs:
with:
fetch-depth: 0 # Make sure you set this, as Gamma needs the Git history

- uses: actions/setup-node@v3

- uses: gravitational/setup-gamma@v1
- uses: actions/setup-node@v4
cache: pnpm

- run: yarn # Install your dependencies as normal
- uses: vincenthsh/setup-gamma@v1

- run: yarn test # Test your actions, if you have tests
- run: pnpm i # Install your dependencies as normal

- run: pnpm test # Test your actions, if you have tests

- name: Deploy actions
run: gamma deploy
Expand Down Expand Up @@ -92,15 +96,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
cache: pnpm # Fork is written for pnpm (and nx)
- uses: gravitational/setup-gamma@v1
- uses: vincenthsh/setup-gamma@v1
- run: yarn # Install your dependencies as normal
- run: pnpm i # Install your dependencies as normal
- run: yarn test # Test your actions, if you have tests
- run: pnpm test # Test your actions, if you have tests
- name: Build actions
run: gamma build
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Setup Gamma
name: Setup Gamma Fork
author: Gravitational, Inc.
description: Build & deploy a monorepo of GitHub Actions into individual repos

Expand All @@ -8,7 +8,7 @@ inputs:
required: false

runs:
using: node16
using: node20
main: dist/index.js

branding:
Expand Down
Loading

0 comments on commit 6f1144c

Please sign in to comment.