diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8005b81..201d6e1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,9 +7,9 @@ "terminal.integrated.defaultProfile.linux": "bash", "terminal.integrated.experimentalRestore": true, "actionButtons": { - "reloadButton": "♻️" /* Custom reload button text */, - "defaultColor": "#ff0034" /* Can also use string color names */, - "loadNpmCommands": false /* Disables automatic generation of actions for npm commands */, + "reloadButton": "♻️", + "defaultColor": "#ff0034", + "loadNpmCommands": false, "commands": [ { "cwd": "${workspaceFolder}", diff --git a/.github/assign.yml b/.github/assign.yml new file mode 100644 index 0000000..6f9ea1f --- /dev/null +++ b/.github/assign.yml @@ -0,0 +1,17 @@ +# Set to true to add reviewers to pull requests +addReviewers: true + +# Set to true to add assignees to pull requests +addAssignees: false + +# A list of reviewers to be added to pull requests (GitHub user name) +reviewers: + - lelouvincx + - thangbuiq + - greyyT + - TuanTran0910 + - ubunchuu-admin + +# A number of reviewers added to the pull request +# Set 0 to add all the reviewers (default: 0) +numberOfReviewers: 0 diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..fa956b7 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,30 @@ +# You can refer README of this repo for future mantainances: https://github.com/actions/labeler + +source: + - changed-files: + - any-glob-to-any-file: + - 'src/**/*' + - '**/*.js' + +content: + - changed-files: + - any-glob-to-any-file: + - blog/**/* + - docs/**/* + +documentation: + - changed-files: + - any-glob-to-any-file: + - docs/**/* + +blog: + - changed-files: + - any-glob-to-any-file: + - blog/**/* + +devops-maintain: + - changed-files: + - any-glob-to-any-file: + - .github/**/* + - .devcontainer/**/* + - Dockerfile diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..f9ff8ca --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,63 @@ +# 🐧 Ubunchuu Contribute Request + + + +## ❓️ What type of PR is this? (check all applicable) + +- [ ] πŸ“ Content - Documentation Update +- [ ] πŸ“ Content - Blog Update +- [ ] 🎨 Style (UI/UX) +- [ ] πŸ• Feature +- [ ] πŸͺ² Bug Fix +- [ ] πŸ€– DevOps +- [ ] πŸ§‘β€πŸ’» Code Refactor + +## πŸ“ Description for my changes + +> Please clear this section and include a very short summary of the change (3 lines maximum) + + + +## πŸ“Œ Related Issues + +> ❗️MANDATORY❗️ + +> Please clear this section and note that any changes to the codebase should have a related issue to provide context for the changes. + + + +## πŸ–₯️ Mobile/Desktop Screenshots (optinal) + + + +> If applicable, add screenshots to help explain your changes. + +> Please clear this whole section if not applicable. + +--- + + + + diff --git a/.github/workflows/auto_assign.yml b/.github/workflows/auto_assign.yml new file mode 100644 index 0000000..194cf27 --- /dev/null +++ b/.github/workflows/auto_assign.yml @@ -0,0 +1,13 @@ +name: 'PR Assigner' +on: + pull_request: + types: [opened, ready_for_review] + +jobs: + add-reviews: + name: Auto + runs-on: ubuntu-22.04 + steps: + - uses: kentaro-m/auto-assign-action@v2.0.0 + with: + configuration-path: '.github/assign.yml' diff --git a/.github/workflows/dependabot.auto.yml b/.github/workflows/auto_dependabot.yml similarity index 89% rename from .github/workflows/dependabot.auto.yml rename to .github/workflows/auto_dependabot.yml index 3dc9969..c579d62 100644 --- a/.github/workflows/dependabot.auto.yml +++ b/.github/workflows/auto_dependabot.yml @@ -1,4 +1,4 @@ -name: Auto approve and merge PRs by dependabot +name: 'Dependabot' on: pull_request: branches: [main] @@ -26,14 +26,15 @@ jobs: USER_EMAIL: 159746302+ubunchuu-admin@users.noreply.github.com APPROVE_TEXT: Legit to bot βœ… - - name: Auto merge + - name: Auto merge for github_actions label + if: contains(github.event.pull_request.labels.*.name, 'github_actions') run: | git config --global user.name "${USER_NAME}" git config --global user.email "${USER_EMAIL}" curl -X PUT \ -H "Authorization: Bearer ${{ secrets.TOKEN_GITHUB }}" \ -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge?merge_method=merge" + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge?merge_method=squash" env: USER_NAME: ubunchuu[bot] USER_EMAIL: 159746302+ubunchuu-admin@users.noreply.github.com diff --git a/.github/workflows/auto_labeler.yml b/.github/workflows/auto_labeler.yml new file mode 100644 index 0000000..a9ce982 --- /dev/null +++ b/.github/workflows/auto_labeler.yml @@ -0,0 +1,14 @@ +name: 'PR Labeler' +on: + pull_request: + types: [opened, ready_for_review, reopened, synchronize] + +jobs: + labeler: + name: Auto + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-22.04 + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/codespaces-image.yml b/.github/workflows/codespaces-image.yml index a296629..fbba37e 100644 --- a/.github/workflows/codespaces-image.yml +++ b/.github/workflows/codespaces-image.yml @@ -1,6 +1,11 @@ -name: Create and publish a Docker image +# Path: .github/workflows/codespaces.yml +name: Codespaces Image on: + pull_request: + branches: ['main'] + paths: + - Dockerfile push: branches: ['main'] paths: @@ -12,8 +17,27 @@ env: IMAGE_NAME: ubunchuu-truong-us/devcontainer:latest jobs: + build-test-image: + name: Test + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: false + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + build-and-push-image: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 + if: github.event_name == 'push' + needs: [build-test-image] permissions: contents: read packages: write @@ -22,14 +46,14 @@ jobs: uses: actions/checkout@v4 - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ env.USER }} password: ${{ secrets.TOKEN_GITHUB }} - name: Build and push Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + uses: docker/build-push-action@v5.0.0 with: context: . push: true diff --git a/.github/workflows/contribute.yml b/.github/workflows/contribute.yml new file mode 100644 index 0000000..85a39e3 --- /dev/null +++ b/.github/workflows/contribute.yml @@ -0,0 +1,34 @@ +name: Create Contribute Pull Request +on: create +permissions: + contents: write + pull-requests: write + id-token: write + +jobs: + create_pull_request: + if: ${{ contains(github.ref, 'refs/heads/content/') }} + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + + - name: Output Branch Name remove the refs/heads/ + run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + + - name: Initial commit to branch by bot + run: | + git checkout ${{ env.branch }} + git config --global user.name "ubunchuu[bot]" + git config --global user.email "159746302+ubunchuu-admin@users.noreply.github.com" + git commit --allow-empty -m "ci: initial commit by bot" + git push origin ${{ env.branch }} + + - name: Open PR + id: open_pr + run: | + gh pr create --title "[AUTOMATIC] Contribute: ${{ env.branch }}" --body-file .github/pull_request_template.md + env: + GH_TOKEN: ${{ secrets.TOKEN_GITHUB }} diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 9ada81f..ef6fa30 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,38 +1,115 @@ -name: Docusaurus Deploy +name: 'Docusaurus CI/CD' on: push: - branches: - - main + branches: ['main'] + pull_request: + branches: ['main'] permissions: contents: read pages: write id-token: write + pull-requests: write jobs: - deploy: + build-and-serve: + name: Test + runs-on: ubuntu-22.04 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Setup Node.js Environment + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install Dependencies + run: | + install_before_time=$(date +%s.%N) + yarn install --frozen-lockfile + install_after_time=$(date +%s.%N) + install_time=$(python -c "print($install_after_time - $install_before_time)") + echo "installTime=$install_time" >> $GITHUB_ENV + + - name: Build Website + run: | + before_time=$(date +%s.%N) + yarn build + after_time=$(date +%s.%N) + build_time=$(python -c "print($after_time - $before_time)") + echo "buildTime=$build_time" >> $GITHUB_ENV + + - name: Verify Build Output + run: | + if [ -d "build" ]; then + echo "Build successful" + else + echo "Build failed" + exit 1 + fi + + - name: Test Server Functionality + run: | + yarn serve & + sleep 5 + kill %1 + + - name: Comment on Pull Request + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.TOKEN_GITHUB }} + script: | + const installTime = process.env.installTime; + const buildTime = process.env.buildTime; + const table = ` + | Step | Time (seconds) | + |----------------------|----------------| + | Install Dependencies | ${installTime} | + | Build Website | ${buildTime} | + `; + const header = `## Performance Report\n- Run number: ${process.env.GITHUB_RUN_NUMBER} \n - Run ID: ${process.env.GITHUB_RUN_ID} \n - Run URL: ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}\n - βœ… Test server functionality passed with the following times for each step:\n`; + const commentBody = `${header}\n\n${table}`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + + deploy-docusaurus: + if: github.event_name == 'push' + needs: [build-and-serve] name: Deploy to GitHub Pages - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - name: Checkout Code (with Submodules) + uses: actions/checkout@v4 with: submodules: 'recursive' - - uses: actions/setup-node@v4 + - name: Setup Node.js Environment + uses: actions/setup-node@v4 with: node-version: '18' - - name: Install dependencies + - name: Install Dependencies run: yarn install --frozen-lockfile - - name: Build website + - name: Build Website run: yarn build - - name: Setup Pages + - name: Configure GitHub Pages uses: actions/configure-pages@v4 - - name: Upload artifact + - name: Upload Website Artifact uses: actions/upload-pages-artifact@v3 with: path: './build' diff --git a/Dockerfile b/Dockerfile index 060f642..3be0a29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,4 +24,6 @@ USER ${DOCKERUSER} # Install starship for non-root user with pure prompt RUN \ sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- --yes -b /home/${DOCKERUSER}/.local/bin && \ - echo 'eval "$(starship init bash && starship preset pure-preset -o ~/.config/starship.toml)"' >> /home/${DOCKERUSER}/.bashrc + echo 'starship preset pure-preset -o ~/.config/starship.toml' >> /home/${DOCKERUSER}/.bashrc && \ + echo 'eval "$(starship init bash)"' >> /home/${DOCKERUSER}/.bashrc +