Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create PRs in new-release.yml #1631

Merged
merged 7 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/build-new-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build New Release

on:
pull_request:
types: [closed]

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Get version
id: get-version
run: |
echo "version=$(printf '%s' '${{ github.event.pull_request.title }}' | awk '{print $3}')" >> $GITHUB_OUTPUT
- name: Set git config
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Get commit msg
id: get-commit-msg
run: |
if [[ -z "${{ steps.get-version.outputs.version }}" ]]; then
echo "msg=deploy: $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "title-deploy=Deploy ref $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
else
echo "msg=deploy: version ${{ steps.get-version.outputs.version }} $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "title-deploy=Deploy version ${{ steps.get-version.outputs.version }} $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
fi
- name: Yarn install
run: |
yarn install --immutable --immutable-cache
- name: Setup .env
run: |
printf '%s' "$ENVFILE" > apps/frontend/.env.local
env:
ENVFILE: ${{ vars.ENVFILE }}
- name: Build genshin-optimizer
run: |
NX_URL_GITHUB_GO_CURRENT_VERSION="https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)" \
yarn run nx run frontend:build-vite:production
- name: Create Deploy PR
run: |
git fetch origin gh-pages --depth=1
git worktree add ../gh-pages gh-pages --no-checkout
cp -rT dist/apps/frontend ../gh-pages
cd ../gh-pages
git add --all .
git commit -m "${{ steps.get-commit-msg.outputs.msg }}"
git push origin HEAD:actions/deploy-gh-pages --force
gh pr create --base gh-pages --head actions/deploy-gh-pages --title '${{ steps.get-commit-msg.outputs.title-deploy }}' --body ''
env:
GH_TOKEN: ${{ github.token }}
- name: Make release
if: steps.get-version.outputs.version != ''
run: |
gh release create ${{ steps.get-version.outputs.version }} --generate-notes --target $(git rev-parse HEAD)
env:
GH_TOKEN: ${{ github.token }}
44 changes: 7 additions & 37 deletions .github/workflows/new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Get version # TODO(eeeqeee) add option to increment from current version
- name: Get version
id: get-version
run: |
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
Expand All @@ -40,38 +34,14 @@ jobs:
id: get-commit-msg
run: |
if [[ -z "${{ steps.get-version.outputs.version }}" ]]; then
echo "msg=deploy: $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "title-release=Release ref $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
else
echo "msg=deploy: version ${{ steps.get-version.outputs.version }} $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "title-release=Release version ${{ steps.get-version.outputs.version }} $(git rev-parse HEAD)" >> $GITHUB_OUTPUT
fi
- name: Yarn install
run: |
yarn install --immutable --immutable-cache
- name: Setup .env
run: |
printf '%s' "$ENVFILE" > apps/frontend/.env.local
env:
ENVFILE: ${{ vars.ENVFILE }}
- name: Build genshin-optimizer
run: |
NX_URL_GITHUB_GO_CURRENT_VERSION="https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)" \
yarn run nx run frontend:build-vite:production
- name: Deploy to Github Pages
run: |
git fetch origin gh-pages --depth=1
git worktree add ../gh-pages gh-pages --no-checkout
cp -rT dist/apps/frontend ../gh-pages
cd ../gh-pages
git add --all .
git commit -m "${{ steps.get-commit-msg.outputs.msg }}"
git push
- name: Push
- name: Create PR
run: |
git status
git push
- name: Make release
if: steps.get-version.outputs.version != ''
run: |
gh release create ${{ steps.get-version.outputs.version }} --generate-notes --target $(git rev-parse HEAD)
git push origin HEAD:actions/new-release --force
gh pr create --base $(git rev-parse --abbrev-ref HEAD) --head actions/new-release --title '${{ steps.get-commit-msg.outputs.title-release }}' --body '' --label release
env:
GH_TOKEN: ${{ github.token }}
Loading