Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add self hosted runner #446

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 36 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,35 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: actions/[email protected]

- name: Config npm token
run: npm config set //npm.pkg.github.com/:_authToken "${GITHUB_TOKEN}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Use Node.js 16.17.0
uses: actions/[email protected]
with:
node-version: 16.17.0
cache: 'npm'

- name: Cache dependencies
id: dep-caches
uses: actions/cache@v2
with:
path: |
node_modules
packages/*/node_modules
!packages/ui/node_modules
key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json', 'packages/*/package-lock.json', '!packages/ui/node_modules') }}
restore-keys: ${{ runner.os }}-build
- name: Config npm token
run: npm config set //npm.pkg.github.com/:_authToken "${GITHUB_TOKEN}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install all deps
run: npm ci --no-audit
# if: steps.prod-dep-caches.outputs.cache-hit != 'true'

# - name: Cache dependencies
# id: dep-caches
# uses: actions/cache@v2
# with:
# path: |
# node_modules
# packages/*/node_modules
# !packages/ui/node_modules
# key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json', 'packages/*/package-lock.json', '!packages/ui/node_modules') }}
# restore-keys: ${{ runner.os }}-build

- name: Cache build result
uses: actions/cache@v2
Expand All @@ -68,22 +72,18 @@ jobs:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
SENTRY_RELEASE: tug-website@${{ github.sha }}

- name: Remove node_modules
run: rm -rf node_modules packages/*/node_modules

- name: Cache prod dependencies
id: prod-dep-caches
uses: actions/cache@v2
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-production-${{ hashFiles('package-lock.json', 'packages/*/package-lock.json') }}
restore-keys: ${{ runner.os }}-production

- name: Install production deps
run: npm ci --no-audit --production --ignore-scripts --unsafe-perm
if: steps.prod-dep-caches.outputs.cache-hit != 'true'
# - name: Remove node_modules
# run: rm -rf node_modules packages/*/node_modules
#
# - name: Cache prod dependencies
# id: prod-dep-caches
# uses: actions/cache@v2
# with:
# path: |
# node_modules
# packages/*/node_modules
# key: ${{ runner.os }}-production-${{ hashFiles('package-lock.json', 'packages/*/package-lock.json') }}
# restore-keys: ${{ runner.os }}-production

# - name: Bundle docker image
# run: docker build . --compress -t tidb-community-website:${{ inputs.build-env }}-${{ runner.os }}-${{ github.sha }}
Expand All @@ -93,6 +93,10 @@ jobs:
# echo ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | docker login ${{ secrets.DOCKER_REGISTRY_ADDRESS }}/${{ secrets.DOCKER_REGISTRY_NAMESPACE }} --username ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin
# docker push tidb-community-website:${{ inputs.build-env }}-${{ runner.os }}-${{ github.sha }}

- name: Install production deps
run: npm ci --no-audit --production --ignore-scripts
# if: steps.prod-dep-caches.outputs.cache-hit != 'true'

- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
runs-on: self-hosted
environment: ${{ inputs.build-env }}
env:
JUMP_SERVER_IP: ${{ secrets.JUMP_SERVER_IP }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
runs-on: self-hosted
environment: ${{ inputs.build-env }}
env:
MAILCHIMP_DC: ${{ secrets.MAILCHIMP_DC }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

preview-pages-test:
needs: [ deploy-preview ]
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: actions/[email protected]

Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
verify:
runs-on: ubuntu-latest
runs-on: self-hosted
permissions:
contents: read
packages: read
Expand All @@ -18,25 +18,25 @@ jobs:
node-version: 16.17.0
cache: 'npm'

- name: Resolve build dependencies
id: dep-caches
uses: actions/cache@v2
with:
path: |
node_modules
packages/*/node_modules
!packages/ui/node_modules
key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json', 'packages/*/package-lock.json', '!packages/ui/node_modules') }}
restore-keys: ${{ runner.os }}-build
# - name: Resolve build dependencies
# id: dep-caches
# uses: actions/cache@v2
# with:
# path: |
# node_modules
# packages/*/node_modules
# !packages/ui/node_modules
# key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json', 'packages/*/package-lock.json', '!packages/ui/node_modules') }}
# restore-keys: ${{ runner.os }}-build

- name: Config npm token
run: npm config set //npm.pkg.github.com/:_authToken "${GITHUB_TOKEN}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install
run: npm ci --no-audit --unsafe-perm
if: steps.dep-caches.outputs.cache-hit != 'true'
run: npm ci --no-audit
# if: steps.dep-caches.outputs.cache-hit != 'true'

- name: Lint
run: npm run lint
Expand Down
Loading