Skip to content

Commit

Permalink
Merge pull request #1 from trueberryless-org/update-template-files
Browse files Browse the repository at this point in the history
[ci] sync template files
  • Loading branch information
trueberryless authored Dec 2, 2024
2 parents e4799a4 + 5c8b23d commit 87d6285
Show file tree
Hide file tree
Showing 16 changed files with 701 additions and 32 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
14 changes: 14 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "trueberryless-org/trueberyless" }
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
13 changes: 11 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
node_modules
.next
Dockerfile
.dockerignore
**/node_modules/
**/.git
README.md
npm-debug.log
.coverage
.coverage.*
.env
.aws
.next
34 changes: 34 additions & 0 deletions .github/labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://github.com/actions/labeler/tree/v5

"🚨 action":
- changed-files:
- any-glob-to-any-file: .github/workflows/**

"πŸ“ changeset":
- changed-files:
- any-glob-to-any-file: "**/.changeset/**.{md,mdx}"

"🚧 config":
- changed-files:
- any-glob-to-any-file: "**/*config*.{js,ts,jsx,tsx,mjs,mts,json,yml,yaml,toml,cjs,cts}"

"βœ’οΈ documentation":
- changed-files:
- any-glob-to-any-file: "**/README.md"

"🌏 i18n":
- changed-files:
- all-globs-to-any-file: ["**/docs/**", "!**/docs/en/**"]

"πŸš€ manifest":
- changed-files:
- any-glob-to-any-file: "manifest*/**"

"πŸ“¦ package":
- changed-files:
- any-glob-to-any-file: "**/packages/**"
- any-glob-to-any-file: "**/package.json"

"🏯 styles":
- changed-files:
- any-glob-to-any-file: "**/*.{css,scss,sass,less,styl}"
201 changes: 201 additions & 0 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: Deployment

on:
push:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
cancel-in-progress: true

env:
REGISTRY: docker.io
IMAGE_OWNER: trueberryless
IMAGE_NAME: trueberryless
NODE_VERSION: 20

jobs:
changes:
name: Filter
runs-on: ubuntu-latest
outputs:
src: ${{ steps.filter.outputs.src }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- 'src/**'
changesets:
name: Changesets
runs-on: ubuntu-latest
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup PNPM
uses: pnpm/action-setup@v3

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"

- name: Install Dependencies
run: pnpm i

- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
with:
commit: "[ci] release"
title: "[ci] release"
env:
GITHUB_TOKEN: ${{ secrets.PUBLIC_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

image-tag:
name: Image Tag
runs-on: ubuntu-latest
outputs:
IMAGE_TAG: ${{ env.IMAGE_TAG }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Read version from package.json
id: get_version
run: |
VERSION=$(jq -r '.version' src/package.json)
echo "IMAGE_TAG=$VERSION" >> $GITHUB_ENV
deployment:
needs: [changes, changesets, image-tag]
if: >
(
needs.changesets.outputs.hasChangesets == 'false' &&
(
contains(github.event.head_commit.message, 'deploy') ||
contains(github.event.head_commit.message, '[ci] release')
)
) ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
package_json_file: ./src/package.json

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: ./pnpm-lock.yaml

- name: Install dependencies
run: pnpm install
shell: bash
working-directory: ./src

- name: Build Website
run: pnpm run build
shell: bash
working-directory: ./src

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ needs.image-tag.outputs.IMAGE_TAG }}
${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}

- name: Update deployment.yaml file
run: |
yq eval '.spec.template.spec.containers[0].image = "${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ needs.image-tag.outputs.IMAGE_TAG }}"' -i manifest/deployment.yaml
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: update deployment.json container image (automated)

release:
name: Release
needs: [image-tag, deployment]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- id: extract-changelog
uses: sean0x42/[email protected]
with:
file: src/CHANGELOG.md
pattern: ${{ needs.image-tag.outputs.IMAGE_TAG }}

- uses: ncipollo/release-action@v1
id: create_release
with:
tag: ${{ env.IMAGE_NAME }}-docs@${{ needs.image-tag.outputs.IMAGE_TAG }}
makeLatest: true
body: ${{ steps.extract-changelog.outputs.markdown }}
skipIfReleaseExists: true

- name: Check if release was created
id: check_release
run: |
if [ -z "${{ steps.create_release.outputs.html_url }}" ]; then
echo "RELEASE_SKIPPED=true" >> $GITHUB_ENV
else
echo "RELEASE_SKIPPED=false" >> $GITHUB_ENV
fi
- name: Discord notification
if: env.RELEASE_SKIPPED == 'false'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
uses: Ilshidur/[email protected]
with:
args: |
# ${{ env.IMAGE_NAME }}@${{ needs.image-tag.outputs.IMAGE_TAG }}
${{ steps.extract-changelog.outputs.markdown }}
43 changes: 43 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Format

on:
push:
branches: [main]

jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
run_install: |
- recursive: false
args: [--frozen-lockfile]
- args: [--global, prettier, sort-package-json]
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Sort package.json
run: find . -name "package.json" -not -path "*/node_modules/*" -exec sort-package-json {} \;
- name: Format with Prettier
run: pnpm prettier --write .
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PUBLIC_GITHUB_TOKEN }}
commit-message: "[ci] format"
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: ci-format
delete-branch: true
title: "[ci] format"
body: "This PR was automatically created to sort package.json files in the repository using sort-package-json and to format the repository using prettier."
labels: πŸ€– bot
assignees: trueberryless
draft: false
30 changes: 30 additions & 0 deletions .github/workflows/generate-readme-tree.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Add tree changes

on:
push:
branches: [main]

jobs:
commit-tree-changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Write tree outputs to README.md
uses: trueberryless-org/readme-tree-writer-all@v1
with:
config_path: .github/readmetreerc.yaml
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PUBLIC_GITHUB_TOKEN }}
commit-message: "[ci] update tree"
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: ci-tree
delete-branch: true
title: "[ci] update tree"
body: "This PR was automatically created to update the project structure tree in every `README.md`."
labels: πŸ€– bot
assignees: trueberryless
draft: false
48 changes: 48 additions & 0 deletions .github/workflows/labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Pull Request Labeler"
on:
- pull_request_target

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ensure labels exist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh label delete "bug" --yes || true
gh label delete "documentation" --yes || true
gh label delete "duplicate" --yes || true
gh label delete "enhancement" --yes || true
gh label delete "good first issue" --yes || true
gh label delete "help wanted" --yes || true
gh label delete "invalid" --yes || true
gh label delete "question" --yes || true
gh label delete "wontfix" --yes || true
gh label create "🚨 action" --description "Changes in GitHub workflows or actions" --color "A75AD5" --force
gh label create "πŸ€– bot" --description "Automatically generated pull request" --color "0075CA" --force
gh label create "πŸ› bug" --description "Something isn't working" --color "D73A4A" --force
gh label create "πŸ“ changeset" --description "Contains changeset files" --color "304EF9" --force
gh label create "🚧 config" --description "Configuration file updates" --color "C0ED4F" --force
gh label create "βœ’οΈ documentation" --description "Documentation updates, like README changes" --color "66741D" --force
gh label create "πŸ” duplicate" --description "This issue or pull request already exists" --color "008672" --force
gh label create "⏫ enhancement" --description "New feature or request" --color "3C11FD" --force
gh label create "πŸ₯‡ good first issue" --description "Good for newcomers" --color "7057FF" --force
gh label create "πŸ†˜ help wanted" --description "Extra attention is needed" --color "BFD4F2" --force
gh label create "🌏 i18n" --description "Updates to internationalized docs, excluding English" --color "006B75" --force
gh label create "πŸ‘€ invalid" --description "This doesn't seem right" --color "E4E669" --force
gh label create "πŸš€ manifest" --description "Manifest-related changes" --color "96D3D7" --force
gh label create "πŸ“¦ package" --description "Updates in package structure or package.json" --color "F34A37" --force
gh label create "❓ question" --description "Further information is requested" --color "D876E3" --force
gh label create "🏯 styles" --description "Stylesheets or design updates" --color "550F5A" --force
gh label create "πŸ”’ wontfix" --description "This will not be worked on" --color "FFFFFF" --force
- uses: actions/labeler@v5
with:
configuration-path: .github/labeler.yaml
sync-labels: true
Loading

0 comments on commit 87d6285

Please sign in to comment.