Skip to content

Commit

Permalink
Add preview workflows, enforce changelog update (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgero-eth authored Jul 12, 2023
1 parent cc33dce commit 190f2a1
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/library-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ jobs:
run: yarn lint
- name: Check prettier
run: yarn prettify
- name: Enforce changelog
if: github.ref != 'refs/heads/main'
uses: dangoslen/[email protected]
66 changes: 66 additions & 0 deletions .github/workflows/storybook-preview-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Storybook Preview Deploy

on:
pull_request:
types:
- labeled
- synchronize

env:
NODE_VERSION: 16
NODE_CACHE: "yarn"

jobs:
deploy-preview:
if: contains(github.event.pull_request.labels.*.name, 'preview')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Setup Node
uses: actions/[email protected]
with:
node-version: ${{ env.NODE_VERSION }}
cache: ${{ env.NODE_CACHE }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build storybook
run: yarn build:storybook
- name: Get previous deployment
uses: peter-evans/[email protected]
id: get-deployment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "Storybook IPFS Hash: "
- name: Setup Python
uses: actions/[email protected]
with:
python-version: "3.x"
architecture: "x64"
- name: Install pyyaml
run: pip install --user pyyaml packaging
- name: Install ipfs-cluster-ctl
run: |
wget https://dist.ipfs.io/ipfs-cluster-ctl/v1.0.0/ipfs-cluster-ctl_v1.0.0_linux-amd64.tar.gz
tar xvfz ipfs-cluster-ctl_v1.0.0_linux-amd64.tar.gz
- name: Unpin from IPFS
continue-on-error: true
if: steps.get-deployment.outputs.comment-id != 0
run: |
COMMENT='${{ steps.get-deployment.outputs.comment-body }}'
IFS=" " read -ra array <<< "$COMMENT"
hash=${array[3]}
./ipfs-cluster-ctl/ipfs-cluster-ctl --basic-auth '${{ secrets.IPFS_BASIC_AUTH }}' --host '${{ secrets.IPFS_HOST }}' pin rm $hash
- name: Pin on IPFS
id: ipfs-pin
run: |
ipfsResult="$(./ipfs-cluster-ctl/ipfs-cluster-ctl --basic-auth '${{ secrets.IPFS_BASIC_AUTH }}' --host '${{ secrets.IPFS_HOST }}' add -r './storybook-static' | tail -1)"
IFS=" " read -ra array <<< "$ipfsResult"
echo "hash=${array[1]}" >> $GITHUB_OUTPUT
- name: Echo url
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Storybook IPFS Hash: ${{ steps.ipfs-pin.outputs.hash }}
ODS deployed to https://ipfs.eth.aragon.network/ipfs/${{ steps.ipfs-pin.outputs.hash }}/
46 changes: 46 additions & 0 deletions .github/workflows/storybook-preview-remove.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Storybook Preview Remove

on:
pull_request:
types:
- unlabeled
- closed

env:
NODE_VERSION: 16
NODE_CACHE: "yarn"

jobs:
remove-preview:
if: contains(github.event.pull_request.labels.*.name, 'preview') || github.event.label.name == 'preview'
runs-on: ubuntu-latest
steps:
- name: Install pyyaml
run: pip install --user pyyaml packaging
- name: Install ipfs-cluster-ctl
run: |
wget https://dist.ipfs.io/ipfs-cluster-ctl/v1.0.0/ipfs-cluster-ctl_v1.0.0_linux-amd64.tar.gz
tar xvfz ipfs-cluster-ctl_v1.0.0_linux-amd64.tar.gz
- name: Get deployment
uses: peter-evans/[email protected]
id: get-deployment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "Storybook IPFS Hash: "
- name: Unpin from IPFS
if: steps.get-deployment.outputs.comment-id != 0
run: |
COMMENT='${{ steps.get-deployment.outputs.comment-body }}'
IFS=" " read -ra array <<< "$COMMENT"
hash=${array[3]}
./ipfs-cluster-ctl/ipfs-cluster-ctl --basic-auth '${{ secrets.IPFS_BASIC_AUTH }}' --host '${{ secrets.IPFS_HOST }}' pin rm $hash
- name: Delete Comment
uses: actions/[email protected]
if: steps.get-deployment.outputs.comment-id != 0
with:
script: |
github.rest.issues.deleteComment({
comment_id: ${{ steps.get-deployment.outputs.comment-id }},
owner: context.repo.owner,
repo: context.repo.repo,
})
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Workflows to deploy Storybook previews
- Step to enforce updates to changelog file

## [0.2.3] - 2023-07-12

### Fixed
Expand Down

0 comments on commit 190f2a1

Please sign in to comment.