From a68d4e6fec2f5c923e17becfe73aed6448ca3cb1 Mon Sep 17 00:00:00 2001 From: mrdcvlsc Date: Sat, 1 Jul 2023 14:58:04 +0800 Subject: [PATCH] build: new workflow updated workflow with semantic-release. --- .github/workflows/format.yml | 57 +++++++++++++++++++++++++++++++++++ .github/workflows/linter.yml | 10 +++--- .github/workflows/release.yml | 45 +++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/format.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..e2aabd6 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,57 @@ +name: format + +# depends of tests.yml +on: + workflow_run: + workflows: [tests] + types: [completed] + +jobs: + format-code: + runs-on: ubuntu-latest + + permissions: + contents: write + + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Email + run: git config --local user.email auto.format@script.yml + + - name: Configure Name + run: git config --local user.name format.yml + + - name: Git Status + run: git status + + - name: Format Code Style + run: npm run format + + - name: Stage Changes + continue-on-error: true + run: git add . + + - name: Save Changes + continue-on-error: true + run: git commit -m "[Auto-format code on push]" -m "Formatted the last commit -> '${{ github.event.head_commit.message }}'" + + - name: Push Changes + continue-on-error: true + run: git push --force + + - name: Done + run: echo done formatting files. + + format-requirements-failed: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - name: rquirements failed + run: echo the tests failed + - name: force fail workflow + run: exit 1 \ No newline at end of file diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 0795493..33da8a9 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -19,7 +19,7 @@ jobs: fetch-depth: 0 - name: Lint Code Base - uses: super-linter/super-linter@v4 + uses: super-linter/super-linter@v5 env: # https://github.com/super-linter/super-linter#environment-variables @@ -28,18 +28,20 @@ jobs: # this decides whether Super Linter should lint the whole codebase # or just the changes introduced with that commit. - VALIDATE_ALL_CODEBASE: false + VALIDATE_ALL_CODEBASE: true # to add a specific language linter,the format is: VALIDATE_{LANGUAGE}_{LINTER} # setting to true will run only the linter. # setting to false will run all linters except it. - VALIDATE_JAVASCRIPT_ES: true + JAVASCRIPT_DEFAULT_STYLE: standard/prettier # VALIDATE_PYTHON_BLACK: true + VALIDATE_JAVASCRIPT_ES: true # VALIDATE_HTML: true + # VALIDATE_CSS: true # where your linter config files should go like; - # .prettierrc.json, .clang-fromat, .eslintrc.yml, .htmlhintrc, etc. + # .clang-fromat, .eslintrc.yml, .htmlhintrc, etc. # the value is default is .github/linters/ # LINTER_RULES_PATH: / diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2a834a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: release + +on: + workflow_run: + workflows: [format] + types: [completed] + +permissions: + contents: read # for checkout + +jobs: + release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install dependencies + run: npm clean-install + + - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies + run: npm audit signatures + + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release + + release-requirements-failed: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - name: requirements failed + run: echo the formatting workflow did not run + - name: force fail release workflow + run: exit 1 \ No newline at end of file