Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into add-us…
Browse files Browse the repository at this point in the history
…er-model
  • Loading branch information
Lisa18289 committed Sep 19, 2024
2 parents d309a35 + df0b8fa commit 1c9f0f5
Show file tree
Hide file tree
Showing 60 changed files with 12,733 additions and 40,335 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish development packages to NPM

on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- dev
workflow_run:
workflows: [Update API client (dev)]
types:
- completed

jobs:
publish:
if:
github.event.pull_request.merged == true ||
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_PAT: ${{ secrets.PUBLISH_PAT }}
GH_TOKEN: ${{ secrets.PUBLISH_PAT }}

steps:
- name: Checkout ⬇️
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PUBLISH_PAT }}
ref: ${{ github.event.workflow_run.head_branch }}

- name: Setup Node 🎛️
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
registry-url: "https://registry.npmjs.org"

- name: Git Identity 🪪
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Yarn Install 📦️
run: yarn install --immutable

- name: Setup NX 1/2 🎛️
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: dev

# This step is needed for nx affected to work when CI is running on a PR
# See also https://nx.dev/ci/recipes/set-up/monorepo-ci-github-actions#configuring-ci-using-github-actions-and-nx
- name: Setup NX 2/2 🎛
if:
(github.ref != 'refs/heads/dev' &&
github.event.workflow_run.head_branch != 'dev')
run: git branch --track dev origin/dev

- name: Build 🔨
run: yarn nx affected -t build --parallel=3

# TODO: Uses the previous version. Needs a fix!
- name: Create version file 🔢
run: |
yarn nx run @mittwald/api-client:build:write-version-file
git add .
- name: Version and publish 🚀
if:
github.event.workflow_run.head_branch == 'dev' || github.ref ==
'refs/heads/dev'
run: |
yarn lerna publish 0.0.0-development-$(git rev-parse --short=7 HEAD)-$(date +%Y%m%d) \
--message "chore(release): bump version to %v" \
--yes --no-private \
--tag-version-prefix "" \
--dist-tag development
12 changes: 10 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ on:

jobs:
publish:
if: github.event.pull_request.merged == true
if:
github.event.pull_request.merged == true ||
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest

env:
Expand Down Expand Up @@ -53,18 +55,24 @@ jobs:
# This step is needed for nx affected to work when CI is running on a PR
# See also https://nx.dev/ci/recipes/set-up/monorepo-ci-github-actions#configuring-ci-using-github-actions-and-nx
- name: Setup NX 2/2 🎛
if: github.ref != 'refs/heads/master'
if:
(github.ref != 'refs/heads/master' &&
github.event.workflow_run.head_branch != 'master')
run: git branch --track master origin/master

- name: Build 🔨
run: yarn nx affected -t build --parallel=3

# TODO: Uses the previous version. Needs a fix!
- name: Create version file 🔢
run: |
yarn nx run @mittwald/api-client:build:write-version-file
git add .
- name: Version and publish 🚀
if:
github.event.workflow_run.head_branch == 'master' || github.ref ==
'refs/heads/master'
run: |
yarn lerna publish \
--conventional-commits \
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/update-client-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update API client (dev)

on:
workflow_dispatch:
push:
branches:
- dev
paths:
- packages/mittwald/spec/openapi-dev.json

jobs:
update-client:
runs-on: ubuntu-latest

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_PAT: ${{ secrets.PUBLISH_PAT }}
GH_TOKEN: ${{ secrets.PUBLISH_PAT }}

steps:
- name: Checkout ⬇️
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PUBLISH_PAT }}

- name: Git Identity 🪪
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Yarn Install 📦️
run: yarn install --immutable

- name: Setup NX 1/2 🎛️
uses: nrwl/nx-set-shas@v4

- name: Setup NX 2/2 🎛
if: github.ref != 'refs/heads/dev'
run: git branch --track master origin/dev

- name: Merge in master ⛙
run: |
git merge refs/remotes/origin/master --strategy-option theirs
- name: Update OpenAPI ⬇️
if: github.ref == 'refs/heads/dev'
run: |
yarn nx run @mittwald/api-client:build:fetch-openapi-dev
if [ $(git status --porcelain . | wc -l) -gt 0 ] ; then
yarn nx run @mittwald/api-client:build:client-dev
git add .
yarn test
git commit -m "chore: update generated development client";
git push origin
fi
7 changes: 4 additions & 3 deletions .github/workflows/update-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Update API client
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
- cron: "0 19 * * *"

jobs:
update-client:
Expand Down Expand Up @@ -38,10 +38,11 @@ jobs:
run: git branch --track master origin/master

- name: Update OpenAPI ⬇️
if: github.ref == 'refs/heads/master'
run: |
yarn nx run @mittwald/api-client:build:fetch-openapi
yarn nx run @mittwald/api-client:build:fetch-openapi-prod
if [ $(git status --porcelain . | wc -l) -gt 0 ] ; then
yarn nx run @mittwald/api-client:build:client
yarn nx run @mittwald/api-client:build:client-prod
git add .
yarn test
git commit -m "feat: update generated client";
Expand Down
Loading

0 comments on commit 1c9f0f5

Please sign in to comment.