Skip to content

Merge pull request #80 from shr0x/main #97

Merge pull request #80 from shr0x/main

Merge pull request #80 from shr0x/main #97

Workflow file for this run

name: Continuous Delivery - Client
on:
push:
branches:
- main
paths:
- packages/client/**
- package.json
- .github/workflows/cd-client.yml
jobs:
pre_ci:
name: Prepare CI environment
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: '[Push] Get commit message'
if: github.event_name == 'push'
id: push_get_commit_message
run: echo ::set-output name=push_commit_message::$(git log --format=%B -n 1 HEAD)
- name: '[Pull Request] Get commit message'
if: github.event_name == 'pull_request'
id: pr_get_commit_message
run: echo ::set-output name=pr_commit_message::$(git log --format=%B -n 1 HEAD^2)
outputs:
commit_message: $( [ -z "${{ steps.pr_get_commit_message.outputs.pr_commit_message }}" ] && echo "${{ steps.push_get_commit_message.outputs.push_commit_message }}" || echo "${{ steps.pr_get_commit_message.outputs.pr_commit_message }}" )
PublishClient:
name: Publish Client
runs-on: ubuntu-latest
if: "!contains(needs.pre_ci.outputs.commit_message, '[skip ci]')"
needs: pre_ci
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js v16 with NPM Registry
uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Publish Types
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
echo -e "\n# Move to the client workspace directory"
cd packages/client
echo -e "\n# Checkout the repo in the target branch"
TARGET_BRANCH="types-client"
git clone $REPO out -b $TARGET_BRANCH
echo -e "\n# Move the generated code to the newly-checked-out repo, to be committed and pushed"
rsync -vaI package.json out/
rsync -vaI README.md out/
rsync -vaI LICENSE out/
rsync -vaI index.d.ts out/
rsync -vaI natives.d.ts out/
rsync -vaI enums.d.ts out/
rsync -vaI game.d.ts out/
rsync -vaI enums/ out/enums
rsync -vaI game/ out/game
echo -e "\n# Commit and push"
cd out
git add --all .
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -m "publish(client): output for ${GITHUB_SHA}" || true
git push origin $TARGET_BRANCH
env:
GITHUB_TOKEN: ${{ secrets.COMMIT_TOKEN }}