0xxlegolas building the game chain smart contracts #24
Workflow file for this run
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: "Build and lint the smart contracts affected by changes committed." | |
run-name: "${{ github.triggering_actor }} building the game chain smart contracts" | |
on: | |
push: | |
branches: | |
- "develop" | |
pull_request: | |
branches: | |
- "develop" | |
workflow_dispatch: | |
create: | |
env: | |
AWS_REGION: eu-west-1 | |
BUCKET_NAME: ${{ vars.BUCKET_NAME}} | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # This is required for git show-ref to work | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8.11.x | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
- name: Install packages | |
run: | | |
pnpm install | |
- name: Audit packages | |
run: | | |
pnpm audit | |
- name: Build feature branch | |
if: github.ref_name != 'develop' #only build on feature branches | |
run: | | |
MAIN_HEAD=$(git rev-parse origin/main) | |
pnpm nx affected -t build --base=$MAIN_HEAD --verbose | |
- name: Build on DEVELOP | |
if: github.ref_name == 'develop' #only build on default branch | |
run: | | |
git show-ref | |
THE_COMMIT_BEFORE_THIS_ONE=$(git rev-parse HEAD~1) | |
echo "rev-parse head~1: " $THE_COMMIT_BEFORE_THIS_ONE | |
pnpm nx affected -t build --base=$THE_COMMIT_BEFORE_THIS_ONE --verbose | |
- name: Lint on feature branch | |
if: github.ref_name != 'develop' #only build on feature branches | |
run: | | |
MAIN_HEAD=$(git rev-parse origin/main) | |
pnpm nx affected -t lint --base=$MAIN_HEAD --verbose | |
- name: Lint project on DEVELOP | |
if: github.ref_name == 'develop' #only build on main branch | |
run: | | |
git show-ref | |
THE_COMMIT_BEFORE_THIS_ONE=$(git rev-parse HEAD~1) | |
echo "rev-parse head~1: " $THE_COMMIT_BEFORE_THIS_ONE | |
pnpm nx affected -t lint --base=$THE_COMMIT_BEFORE_THIS_ONE --verbose | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: build_outputs | |