Skip to content

Commit

Permalink
ci(gh-actions): change release workflow (#962)
Browse files Browse the repository at this point in the history
* ci(gh-actions): add deploy job

* docs(readme): change badge description

* ci(gh-actions): add change tag job

* ci(gh-actions): add release assets vars
  • Loading branch information
nogic1008 committed May 3, 2024
1 parent cf89b93 commit 9e13690
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 10 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: Node.js CI/CD

on:
push:
Expand Down Expand Up @@ -155,3 +155,35 @@ jobs:
repo: context.repo.repo,
body: `${message} [Show More](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`
})
deploy:
name: Deploy to Release branch
if: github.event_name == 'push'
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout Release Branch
uses: actions/checkout@v4.1.4
with:
ref: ${{ vars.RELEASE_BRANCH }}

- name: Checkout Documents from main
uses: actions/checkout@v4.1.4
with:
sparse-checkout: ${{ vars.RELEASE_ASSETS }}
sparse-checkout-cone-mode: false

- name: Download Build Assets
uses: actions/download-artifact@v4.1.7
with:
name: dist
path: dist

- name: Commit and Push
continue-on-error: true
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "build: deploy via ${{ github.sha }}"
git push
24 changes: 17 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ on:
jobs:
release:
name: Release
if: github.event.release.prerelease == false
runs-on: ubuntu-latest
steps:
- name: Release for GitHub Actions
uses: technote-space/release-github-actions@v8.0.3
with:
BRANCH_NAME: releases/${MAJOR}
BUILD_COMMAND: npm ci --ignore-scripts && npm run build && npm pkg delete scripts.prepare
CLEAN_TARGETS: .[!.]*,test,coverage,node_modules,src,*.js,*.ts,*.json,*.lock,_config.yml
COMMIT_MESSAGE: 'build: release ${{ github.event.release.tag_name }} via ${{ github.sha }}'
- name: Checkout
uses: actions/checkout@v4.1.4

- name: Get Major & Minor version
id: version
run: |
echo "major=$(echo ${{ github.event.release.tag_name }} | cut -d. -f1)" >> $GITHUB_OUTPUT
echo "minor=$(echo ${{ github.event.release.tag_name }} | cut -d. -f2)" >> $GITHUB_OUTPUT
- name: Push Git Tag (Major, Minor)
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git tag -a ${{ steps.version.outputs.major }}
git tag -a ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}
git push --tags --force
2 changes: 1 addition & 1 deletion README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![last commit](https://img.shields.io/github/last-commit/ddradar/lgtm-action 'last commit')](https://github.com/ddradar/lgtm-action/commits)
[![release version](https://img.shields.io/github/v/release/ddradar/lgtm-action 'release version')](https://github.com/ddradar/lgtm-action/releases)
[![Node.js CI](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml/badge.svg)](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml)
[![Node.js CI/CD](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml/badge.svg)](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml)
[![codecov](https://codecov.io/gh/ddradar/lgtm-action/branch/main/graph/badge.svg?token=9NHUlO6fhV)](https://codecov.io/gh/ddradar/lgtm-action)
[![CodeFactor](https://www.codefactor.io/repository/github/ddradar/lgtm-action/badge)](https://www.codefactor.io/repository/github/ddradar/lgtm-action)
[![License](https://img.shields.io/github/license/ddradar/lgtm-action)](LICENSE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![last commit](https://img.shields.io/github/last-commit/ddradar/lgtm-action 'last commit')](https://github.com/ddradar/lgtm-action/commits)
[![release version](https://img.shields.io/github/v/release/ddradar/lgtm-action?sort=semver 'release version')](https://github.com/ddradar/lgtm-action/releases)
[![Node.js CI](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml/badge.svg)](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml)
[![Node.js CI/CD](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml/badge.svg)](https://github.com/ddradar/lgtm-action/actions/workflows/nodejs.yml)
[![codecov](https://codecov.io/gh/ddradar/lgtm-action/branch/main/graph/badge.svg?token=9NHUlO6fhV)](https://codecov.io/gh/ddradar/lgtm-action)
[![CodeFactor](https://www.codefactor.io/repository/github/ddradar/lgtm-action/badge)](https://www.codefactor.io/repository/github/ddradar/lgtm-action)
[![License](https://img.shields.io/github/license/ddradar/lgtm-action)](LICENSE)
Expand Down

0 comments on commit 9e13690

Please sign in to comment.