Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ansidev committed Feb 23, 2023
0 parents commit f9fbdf5
Show file tree
Hide file tree
Showing 44 changed files with 7,280 additions and 0 deletions.
Empty file added .changes/unreleased/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions .changie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
changesDir: .changes
unreleasedDir: unreleased
headerPath: ../.chglog/CHANGELOG_HEADER.tpl.md
changelogPath: CHANGELOG.md
versionExt: md
newlines:
afterChangelogHeader: 0
beforeChangelogVersion: 1
endOfVersion: 1
replacements:
- path: "package.json"
find: '"version": ".*"'
replace: '"version": "{{.VersionNoPrefix}}"'
19 changes: 19 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{ range .Versions -}}
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
{{ range .CommitGroups }}
### {{ .Title }}
{{ range .Commits }}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end -}}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end }}
Full Changelog: {{ if .Tag.Previous }}[{{ .Tag.Previous.Name }}...{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/commits/{{ .Tag.Name }}){{ end }}
{{ end -}}
5 changes: 5 additions & 0 deletions .chglog/CHANGELOG_HEADER.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
30 changes: 30 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/ansidev/astro-basic-template
options:
commits:
filters:
Type:
- feat
- fix
- perf
- refactor
- docs
commit_groups:
title_maps:
feat: Features
fix: Bug Fixes
perf: Performance Improvements
refactor: Code Refactoring
docs: Documentations
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject
notes:
keywords:
- BREAKING CHANGE
5 changes: 5 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@commitlint/config-conventional"
]
}
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "./node_modules/cz-conventional-changelog"
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
53 changes: 53 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const { quotes, semicolon } = require('./eslint.config.cjs')

module.exports = {
plugins: ['simple-import-sort'],
env: {
browser: true,
node: true
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
rules: {
'comma-spacing': [
'error',
{
'before': false,
'after': true
}
],
'quotes': ['error', quotes],
'astro/semi': ['error', semicolon ? 'always' : 'never'],
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
overrides: [
{
files: ['*.astro'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:astro/recommended',
],
parser: 'astro-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro'],
},
},
{
files: ['*.ts'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
],
parser: '@typescript-eslint/parser',
},
{
files: ['*.mjs'],
extends: ['eslint:recommended'],
}
]
}
16 changes: 16 additions & 0 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# These are supported funding model platforms

github: [ansidev]
patreon: ansidev
# open_collective: # Replace with a single Open Collective username
ko_fi: ansidev
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
# liberapay: # Replace with a single Liberapay username
# issuehunt: # Replace with a single IssueHunt username
# otechie: # Replace with a single Otechie username
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom:
- "https://www.paypal.me/ansidev"
- "https://www.buymeacoffee.com/ansidev"
- "https://me.momo.vn/ansidev"
40 changes: 40 additions & 0 deletions .github/workflows/auto_merge_release_hotfix_into_develop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: auto_merge_release_hotfix_into_develop

on:
pull_request:
types:
- opened
branches:
- develop

env:
BRANCH_DEVELOP: develop

jobs:
auto_merge:
name: Merge release into develop
runs-on: ubuntu-latest
permissions:
contents: write
# only merge pull requests that begin with 'release/' or 'hotfix/'
if: startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/')

steps:
- name: Set GitHub token
run: |
echo "GH_TOKEN=${{ secrets.GH_TOKEN }}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ env.GH_TOKEN }}
# needed by "gh pr create"
fetch-depth: 0

- name: Merge PR
env:
PR_NUMBER: ${{ github.event.number }}
PR_TITLE: Merge branch '${{ github.head_ref }}' into ${{ env.BRANCH_DEVELOP }}
run: |
gh pr merge ${PR_NUMBER} -m -d -t "${PR_TITLE}"
191 changes: 191 additions & 0 deletions .github/workflows/deploy_to_netlify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: deploy_to_netlify

on:
pull_request:
branches:
- main
- develop
types:
- opened
- synchronize
- closed

env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
DEPLOY_DIR: dist

jobs:
set_deploy_environment:
if: github.event.action != 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Set deploy environment as pr-${{ github.event.number }}
if: github.base_ref == 'develop' && contains(fromJSON('["opened", "synchronize"]'), github.event.action)
env:
DEPLOY_ENVIRONMENT: pr-${{ github.event.number }}
run: |
echo "DEPLOY_ENVIRONMENT=$DEPLOY_ENVIRONMENT" >> $GITHUB_ENV
echo "NETLIFY_DEPLOY_PREFIX=${DEPLOY_ENVIRONMENT}--" >> $GITHUB_ENV
echo "NETLIFY_DEPLOY_ALIAS=$DEPLOY_ENVIRONMENT" >> $GITHUB_ENV
- name: Set deploy environment as preview
if: github.base_ref == 'develop' && github.event.action == 'closed' && github.event.pull_request.merged == true
env:
DEPLOY_ENVIRONMENT: preview
PR_DEPLOY_ENVIRONMENT: pr-${{ github.event.number }}
run: |
echo "DEPLOY_ENVIRONMENT=$DEPLOY_ENVIRONMENT" >> $GITHUB_ENV
echo "PR_DEPLOY_ENVIRONMENT=$PR_DEPLOY_ENVIRONMENT" >> $GITHUB_ENV
echo "NETLIFY_DEPLOY_PREFIX=${DEPLOY_ENVIRONMENT}--" >> $GITHUB_ENV
echo "NETLIFY_DEPLOY_ALIAS=$DEPLOY_ENVIRONMENT" >> $GITHUB_ENV
- name: Set deploy environment as staging
if: github.base_ref == 'main' && contains(fromJSON('["opened", "synchronize"]'), github.event.action)
env:
DEPLOY_ENVIRONMENT: staging
run: |
echo "DEPLOY_ENVIRONMENT=$DEPLOY_ENVIRONMENT" >> $GITHUB_ENV
echo "NETLIFY_DEPLOY_PREFIX=${DEPLOY_ENVIRONMENT}--" >> $GITHUB_ENV
echo "NETLIFY_DEPLOY_ALIAS=$DEPLOY_ENVIRONMENT" >> $GITHUB_ENV
- name: Set deploy environment as production
if: github.base_ref == 'main' && github.event.action == 'closed' && github.event.pull_request.merged == true
run: echo "DEPLOY_ENVIRONMENT=production" >> $GITHUB_ENV

- name: Set deploy environment output
id: deploy_environment
run: |
echo "github_environment=$DEPLOY_ENVIRONMENT" >> $GITHUB_OUTPUT
echo "github_pr_environment=$PR_DEPLOY_ENVIRONMENT" >> $GITHUB_OUTPUT
echo "netlify_deploy_prefix=$NETLIFY_DEPLOY_PREFIX" >> $GITHUB_OUTPUT
echo "netlify_deploy_alias=$NETLIFY_DEPLOY_ALIAS" >> $GITHUB_OUTPUT
outputs:
github_environment: ${{ steps.deploy_environment.outputs.github_environment }}
github_pr_environment: ${{ steps.deploy_environment.outputs.github_pr_environment }}
netlify_deploy_prefix: ${{ steps.deploy_environment.outputs.netlify_deploy_prefix }}
netlify_deploy_alias: ${{ steps.deploy_environment.outputs.netlify_deploy_alias }}

deploy:
if: github.event.action != 'closed' || github.event.pull_request.merged == true
needs: set_deploy_environment
environment:
name: ${{ needs.set_deploy_environment.outputs.github_environment }}
url: ${{ steps.post_deploy.outputs.netlify_deploy_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 7
run_install: false

- name: Get PNPM store directory
id: pnpm-cache
run: echo "pnpm_store_path=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_store_path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Install Netlify CLI
run: pnpm add --save-dev netlify-cli

- name: Set as production environment
if: needs.set_deploy_environment.outputs.github_environment == 'production'
run: echo "PROD=true" >> $GITHUB_ENV

- name: Deploy ${{ needs.set_deploy_environment.outputs.github_environment }}
id: deploy
if: success()
env:
NETLIFY_DEPLOY_PREFIX: ${{ needs.set_deploy_environment.outputs.netlify_deploy_prefix }}
NETLIFY_DEPLOY_ALIAS: ${{ needs.set_deploy_environment.outputs.netlify_deploy_alias }}
shell: bash
run: |
set -e
[[ ${PROD:-false} == "true" ]] && \
OUTPUT=$(pnpm netlify deploy \
--auth ${{ env.NETLIFY_AUTH_TOKEN }} \
--site ${{ env.NETLIFY_SITE_ID }} \
--json \
--build \
--context production \
--message "$(git log -1 --pretty=%s)" \
--prod \
| tr '\n' ' ') || \
OUTPUT=$(pnpm netlify deploy \
--auth ${{ env.NETLIFY_AUTH_TOKEN }} \
--site ${{ env.NETLIFY_SITE_ID }} \
--json \
--build \
--context deploy-preview \
--alias ${NETLIFY_DEPLOY_ALIAS} \
--message "$(git log -1 --pretty=%s)" \
| tr '\n' ' ')
set +e
NETLIFY_OUTPUT=$(echo "$OUTPUT")
echo "netlify_output=$NETLIFY_OUTPUT" >> $GITHUB_OUTPUT
echo "success=true" >> $GITHUB_OUTPUT
- name: Post deploy ${{ needs.set_deploy_environment.outputs.github_environment }}
id: post_deploy
if: success()
env:
NETLIFY_DRAFT_URL: ${{ fromJson(steps.deploy.outputs.netlify_output).deploy_url }}
NETLIFY_PROD_URL: ${{ fromJson(steps.deploy.outputs.netlify_output).url }}
run: |
[[ ${PROD:-false} == "true" ]] && \
echo "netlify_deploy_url=$NETLIFY_PROD_URL" >> $GITHUB_OUTPUT || \
echo "netlify_deploy_url=$NETLIFY_DRAFT_URL" >> $GITHUB_OUTPUT
outputs:
success: ${{ steps.deploy.outputs.success }}

delete_resources:
needs:
- set_deploy_environment
- deploy
if: needs.deploy.outputs.success == 'true' &&
github.base_ref == 'develop' &&
github.event.action == 'closed' &&
github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Delete the PR branch after merged into develop
env:
GH_TOKEN: ${{ github.token }}
GIT_REF_PATH: /repos/${{ github.repository }}/git/refs/heads/${{ github.head_ref }}
run: |
STATUS_CODE=$(gh api -i -H "Accept: application/vnd.github+json" $GIT_REF_PATH | head -1)
[[ "$STATUS_CODE" == "HTTP/2.0 200 OK" ]] && \
gh api --method DELETE -H "Accept: application/vnd.github+json" $GIT_REF_PATH || \
echo "Branch does not exist, deleting was ignored."
- name: Delete the environment ${{ needs.set_deploy_environment.outputs.github_pr_environment }}
if: needs.set_deploy_environment.outputs.github_pr_environment != ''
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/environments/${{ needs.set_deploy_environment.outputs.github_pr_environment }}
Loading

0 comments on commit f9fbdf5

Please sign in to comment.