Skip to content

Commit

Permalink
Checking CI/CD. (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: Vedansh <superuser.ntsystems@outlook.com>
  • Loading branch information
TheHamsterBot and offensive-vk authored Sep 22, 2024
1 parent e451cc5 commit a3db040
Show file tree
Hide file tree
Showing 24 changed files with 43,839 additions and 26,406 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "GitHub Actions (TypeScript)",
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
"postCreateCommand": "npm install",
"postCreateCommand": "npx pnpm i",
"customizations": {
"codespaces": {
"openFiles": ["README.md"]
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.dockerignore
**/.env
**/.git
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ updates:
- minor
- patch

- package-ecosystem: npm
- package-ecosystem: bundler
directory: /
schedule:
interval: weekly
Expand Down
11 changes: 11 additions & 0 deletions .github/linters/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'

export default [
{ files: ['**/*.{js,mjs,cjs,ts}'] },
{ ignores: ['dist/**', 'node_modules/**', 'lib/**', '.github/**'] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended
]
66 changes: 33 additions & 33 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: CI / Build & Test

on:
schedule:
- cron: "0 */4 * * *"
- cron: '0 */4 * * *'
push:
branches: ["master", "**"]
branches: ['master', '**']
pull_request:
branches: ["master", "**"]
branches: ['master', '**']
workflow_dispatch:

concurrency:
Expand All @@ -32,61 +32,61 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Setup pnpm@v9
run: npm i -g pnpm@9.0.0; pnpm -v

- run: pnpm i
- run: pnpm run bundle

on_macos:
runs-on: macos-latest
continue-on-error: true
strategy:
matrix:
node-version: [18.x, 19.x, 20.x, 21.x, 22.x]
name: Macos - Build & Test on v${{ matrix.node-version }}

name: Macos - Build & Test on v${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup pnpm@v9
run: npm i -g pnpm@9.0.0; pnpm -v
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Setup pnpm@v9
run: npm i -g pnpm@9.0.0; pnpm -v

- run: pnpm i
- run: pnpm run bundle
- run: pnpm i
- run: pnpm run bundle

on_windows:
runs-on: windows-latest
continue-on-error: true
strategy:
matrix:
node-version: [18.x, 19.x, 20.x, 21.x, 22.x]

name: Windows - Build & Test on v${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Setup pnpm@v9
run: npm i -g pnpm@9.0.0; pnpm -v
- name: Setup pnpm@v9
run: npm i -g pnpm@9.0.0; pnpm -v

- run: pnpm i
- run: pnpm run bundle
- run: pnpm i
- run: pnpm run bundle

job_summary:
needs: [on_linux, on_windows, on_macos]
continue-on-error: false
runs-on: ubuntu-latest
steps:
- name: Job Summary
run: echo "🎉 The job was successful."
needs: [on_linux, on_windows, on_macos]
continue-on-error: false
runs-on: macos-latest
steps:
- name: Job Summary
run: echo "🎉 The job was successful."
7 changes: 3 additions & 4 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ permissions:

jobs:
check-dist:
name: Check dist/
name: Check Distribution Directory
runs-on: ubuntu-latest

steps:
Expand All @@ -35,15 +35,14 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
id: install
run: npm ci
run: npm i -g pnpm@9.0.0; pnpm i

- name: Build dist/ Directory
id: build
run: npm run bundle
run: pnpm run bundle

# This will fail the workflow if the `dist/` directory is different than
# expected.
Expand Down
37 changes: 20 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
name: CI

on:
pull_request:
branches:
- dev
schedule:
- cron: '0 */4 * * *'
push:
branches:
- dev
branches: ['dev', '**']
pull_request:
branches: ['dev', '**']
workflow_dispatch:

permissions:
contents: read

jobs:
test-typescript:
name: TypeScript Tests
runs-on: ubuntu-latest

name: Test TypeScript
strategy:
fail-fast: true
steps:
- name: Checkout
id: checkout
Expand All @@ -29,25 +31,26 @@ jobs:
cache: npm

- name: Install Dependencies
id: npm-ci
run: npm ci
id: pnpm-ci
run: npm run setup

- name: Check Format
id: npm-format-check
run: npm run format:check
id: pnpm-format-check
run: pnpm run format:check

- name: Lint
id: npm-lint
run: npm run lint
id: pnpm-lint
run: pnpm run lint

- name: Test
id: npm-ci-test
run: npm run ci-test
id: pnpm-test
run: pnpm run test

test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest

name: Test Action
strategy:
fail-fast: true
steps:
- name: Checkout
id: checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- dev
schedule:
- cron: '31 7 * * 3'
- cron: '0 */4 * * *'

permissions:
actions: read
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
tags:
- '*'
schedule:
- cron: '0 0 1 * *'
- cron: '0 0 1 * *'
workflow_dispatch:

env:
USERNAME: ${{ github.repository_owner }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TOKEN: ${{ secrets.GITHUB_TOKEN || secrets.BOT_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: read
Expand Down Expand Up @@ -55,4 +55,4 @@ jobs:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
80 changes: 80 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI / Deploy to DockerHub

on:
schedule:
- cron: '15 0 * * 0'
workflow_dispatch:

env:
REGISTRY: docker.io
IMAGE_NAME: ${{ secrets.DOCKER_USER }}/${{ secrets.DOCKER_IMAGE }}
USERNAME: ${{ secrets.DOCKER_USER }}
PASSWORD: ${{ secrets.DOCKER_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker Image
run: docker build . --file Dockerfile -t develop-actions:dev

deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Log into Registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ env.PASSWORD }}

- name: Extract Docker Metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and Push Docker Image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Sign the Docker Image
if: ${{ github.event_name != 'pull_request' }}
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "Image with ${TAGS} tag has been sucessfully Signed."

- name: Upload Labels and Tags
if: ${{ github.event_name != 'pull_request' }}
run: |
echo "## Summary - Docker CI " >> $GITHUB_STEP_SUMMARY
echo "Tags: ${{ steps.meta.outputs.tags }} " >> $GITHUB_STEP_SUMMARY
echo "Labels: ${{ steps.meta.outputs.labels }} " >> $GITHUB_STEP_SUMMARY
echo "Digest: ${{ steps.build-and-push.outputs.digest }} " >> $GITHUB_STEP_SUMMARY
echo "*** VERIFICATION COMPLETED ***" >> $GITHUB_STEP_SUMMARY
Loading

0 comments on commit a3db040

Please sign in to comment.