Skip to content

Commit

Permalink
build: new workflow
Browse files Browse the repository at this point in the history
updated workflow with semantic-release.
  • Loading branch information
mrdcvlsc committed Jul 1, 2023
1 parent 23b82e5 commit 8d73f8b
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 6 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]

- 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
10 changes: 6 additions & 4 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: /

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 25 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tic-tac-toe-minimax",
"version": "1.0.2",
"version": "0.0.0",
"description": "A tic-tac-toe web application that has a computer player that uses the minimax algorithm to make moves.",
"main": "tests.js",
"scripts": {
Expand All @@ -13,11 +13,34 @@
"author": "mrdcvlsc",
"license": "MIT",
"devDependencies": {
"prettier": "^2.8.8"
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^10.0.4",
"@semantic-release/release-notes-generator": "^11.0.3",
"prettier": "^2.8.8",
"semantic-release": "^21.0.6"
},
"type": "module",
"dependencies": {
"@fastify/static": "^6.10.2",
"fastify": "^4.18.0"
},
"release": {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
"@semantic-release/changelog",
"@semantic-release/git"
],
"branches": [
"main"
]
}
}

0 comments on commit 8d73f8b

Please sign in to comment.