-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9509ca1
commit fb32952
Showing
216 changed files
with
4,865 additions
and
15,221 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,137 +2,58 @@ name: CI | |
|
||
on: [push, pull_request] | ||
|
||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
|
||
jobs: | ||
docker-build: | ||
name: Build Docker image | ||
build: | ||
name: Build | ||
|
||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 10 | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: Checkout git repository | ||
- name: Checkout Git repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
install: true | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
node-version: "18" | ||
cache: "yarn" | ||
- name: Install dependencies with Yarn | ||
run: yarn install --immutable | ||
- name: Pull latest image | ||
run: docker pull zwsim/zws:latest | ||
- name: Build Docker image | ||
# run: docker buildx build --pull --tag zwsim/zws:latest --platform linux/amd64,linux/arm64 . | ||
run: docker buildx build --pull --tag zwsim/zws:latest --platform linux/amd64 . | ||
test: | ||
name: Test | ||
|
||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 15 | ||
|
||
services: | ||
postgres: | ||
image: postgres:15 | ||
env: | ||
POSTGRES_USER: test | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: zws | ||
ports: | ||
- '5432:5432' | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Checkout git repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
- name: Pull environment variables | ||
run: yarn vercel env pull --environment development .env --token ${{ secrets.VERCEL_TOKEN }} | ||
- name: Cache Next.js | ||
uses: actions/cache@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
- name: Install dependencies with Yarn | ||
run: yarn install --immutable | ||
- name: Run migrations | ||
run: yarn run migrations | ||
env: | ||
DATABASE_URL: postgres://test:password@localhost:5432/zws | ||
- name: Run tests | ||
run: yarn test | ||
env: | ||
SMOKE_TEST: true | ||
DATABASE_URL: postgres://test:password@localhost:5432/zws | ||
timeout-minutes: 5 | ||
lint-dockerfile: | ||
name: Lint Dockerfile | ||
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node | ||
path: | | ||
~/.npm | ||
${{ github.workspace }}/.next/cache | ||
# Generate a new cache whenever packages or source files change. | ||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | ||
# If source files changed but packages didn't, rebuild from a prior cache. | ||
restore-keys: | | ||
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | ||
- name: Build | ||
run: yarn run build | ||
lint: | ||
name: Lint | ||
|
||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: Checkout git repository | ||
uses: actions/checkout@v3 | ||
- name: Lint Dockerfile | ||
uses: hadolint/[email protected] | ||
with: | ||
dockerfile: Dockerfile | ||
deploy: | ||
name: Deploy | ||
|
||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 30 | ||
|
||
# Don't run this job if we aren't on main branch | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
|
||
needs: [test, docker-build, lint-dockerfile] | ||
|
||
steps: | ||
- name: Checkout git repository | ||
- name: Checkout Git repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
node-version: "18" | ||
cache: "yarn" | ||
- name: Install dependencies with Yarn | ||
run: yarn install --immutable | ||
- name: Build | ||
run: yarn run build | ||
- name: Setup Git for committing | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "zws.im" | ||
git remote add github "https://[email protected]/$GITHUB_REPOSITORY.git" | ||
git fetch github | ||
- name: Configure npm | ||
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Update versions with changesets | ||
run: yarn changeset version | ||
- name: Publish with changesets | ||
run: | | ||
yarn changeset publish | ||
git add -A | ||
# Exit succesfully if no changes | ||
git commit -m "build: release" || exit 0 | ||
git push --follow-tags -u github main | ||
env: | ||
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Lint | ||
run: yarn run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.