CD for PR: #88 chore(deps): update all non-major dependencies #73
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: CD | |
run-name: 'CD for PR: #${{github.event.pull_request.number}} ${{ github.event.pull_request.title }}' | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
concurrency: | |
group: cd-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com' | |
GH_USER: 'github-actions[bot]' | |
jobs: | |
check-release: | |
name: Check release | |
if: ${{ startsWith(github.head_ref, 'release/') && github.event.pull_request.merged == true }} | |
runs-on: ubuntu-latest | |
outputs: | |
is_release: ${{ steps.check.outputs.is_release }} | |
steps: | |
- name: check | |
id: check | |
run: | | |
SOURCE="${{ github.head_ref }}" | |
TARGET="${{ github.base_ref }}" | |
VAR_NAME="is_release" | |
if [[ ${SOURCE} == release/* ]] && [[ ${TARGET} == "main" ]]; then | |
RESULT="${VAR_NAME}=1" | |
else | |
RESULT="${VAR_NAME}=0" | |
fi | |
echo "${RESULT}" | |
echo "${RESULT}" >>"${GITHUB_OUTPUT}" | |
test: | |
needs: | |
- check-release | |
if: ${{ needs.check-release.outputs.is_release > 0 }} | |
uses: ./.github/workflows/test.yml | |
get-version: | |
name: Get versioon from package.json | |
runs-on: ubuntu-latest | |
needs: | |
- check-release | |
if: ${{ startsWith(github.head_ref, 'release/') && (needs.check-release.outputs.is_release > 0)}} | |
outputs: | |
app-version: ${{ steps.identify-version.outputs.app-version }} | |
app-version-text: ${{ steps.identify-version.outputs.app-version-text }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Parse package.json | |
id: identify-version | |
run: | | |
APP_VERSION="$(cat ./package.json |jq .version|sed -e 's/"//g'| head -n1)" | |
if [ ! -n "${APP_VERSION}" ]; then | |
exit 255 | |
fi | |
echo "Detected the version: ${APP_VERSION}" | |
echo "app-version=${APP_VERSION}" >>"${GITHUB_OUTPUT}" | |
echo "app-version-text=v${APP_VERSION}" >>"${GITHUB_OUTPUT}" | |
tag: | |
name: Add the tag for the released version | |
needs: | |
- test | |
- check-release | |
- get-version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
# required | |
app-id: ${{ vars.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
- name: Configration for git | |
run: | | |
git config --global user.name "${GH_USER}" | |
git config --global user.email "${GH_EMAIL}" | |
- name: Checkout | |
env: | |
GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ env.GH_TOKEN }} | |
- name: Add the release tag | |
env: | |
GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
APP_VERSION_TEXT: ${{ needs.get-version.outputs.app-version-text }} | |
run: | | |
echo "Create tag: ${APP_VERSION_TEXT}" | |
git tag "${APP_VERSION_TEXT}" | |
git push origin "${APP_VERSION_TEXT}" |