Skip to content

ci: remove sha tracker so it can run in CI manually #298

ci: remove sha tracker so it can run in CI manually

ci: remove sha tracker so it can run in CI manually #298

name: Continuous Deployment
on:
push:
branches:
- main
paths:
- 'src/**'
- '.github/workflows/continuous-deployment.yml'
- 'README.md'
- 'Dockerfile'
workflow_dispatch:
inputs:
skip-publish:
description: 'Whether to skip publishing typings to NPM'
required: false
jobs:
Publish:
name: Publish image to container registries
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip docker]')"
steps:
- name: Checkout Project
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2.2.1
- name: Login to DockerHub
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3.2.0
with:
push: true
context: .
tags: |
favware/graphql-pokemon:latest
ghcr.io/favware/graphql-pokemon:latest
- name: Update repo description
uses: peter-evans/dockerhub-description@v3.1.1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: favware/graphql-pokemon
short-description: Extensive Pokemon GraphQL API
GenerateTypings:
name: Generate TypeScript, and SDL type information
runs-on: ubuntu-latest
if: >-
!(contains(github.event.head_commit.message, '[skip publish]')
||github.event.inputs.skip-publish == true)
needs: Publish
services:
pokedex:
image: ghcr.io/favware/graphql-pokemon:latest
options: >-
--health-cmd "nc -z localhost 4000"
--health-interval 10s
--health-timeout 10s
--health-retries 6
--health-start-period 5s
ports:
- 4000:4000
steps:
- name: Checkout Project
uses: actions/checkout@v3
- name: Add problem matchers
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v20
uses: actions/setup-node@v3
with:
node-version: 20
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Generate GraphQL Schema code
run: yarn codegen
- name: Upload typescript bundle to artifacts
uses: actions/upload-artifact@v3
with:
name: typescript_bundle
path: dist/
if-no-files-found: error
GitHubCreateTag:
name: Create tag on GitHub
runs-on: ubuntu-latest
if: >-
!(contains(github.event.head_commit.message, '[skip publish]')
||github.event.inputs.skip-publish == true)
needs: GenerateTypings
steps:
- name: Checkout Project
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.BOT_TOKEN }}
- name: Use Node.js v20
uses: actions/setup-node@v3
with:
node-version: 20
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Configure Git
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_EMAIL}"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
GITHUB_USER: Favware-bot
GITHUB_EMAIL: favwarebot@gmail.com
- name: Set up git-cliff
uses: kenji-miyake/setup-git-cliff@v1
- name: Bump semver
if: "!contains(github.event.head_commit.message, '[skip bump]')"
run: yarn bump --no-skip-tag --no-skip-changelog
env:
CI: false
- name: Store bumped package.json
uses: actions/upload-artifact@v3
with:
name: package_bundle
path: package.json
if-no-files-found: error
- name: Store bumped changelog.md
uses: actions/upload-artifact@v3
with:
name: changelog_bundle
path: CHANGELOG.md
if-no-files-found: error
- name: Push changes
if: "!contains(github.event.head_commit.message, '[skip bump]')"
run: git push origin main && git push --tags origin main
NPMPublish:
name: Publishing release to NPM
runs-on: ubuntu-latest
if: >-
!(contains(github.event.head_commit.message, '[skip publish]')
||github.event.inputs.skip-publish == true)
needs: GitHubCreateTag
steps:
- name: Checkout Project
uses: actions/checkout@v3
- name: Download generated typings artifact
uses: actions/download-artifact@v3
with:
name: typescript_bundle
path: dist/
- name: Download stored package.json
uses: actions/download-artifact@v3
with:
name: package_bundle
- name: Download stored changelog.md
uses: actions/download-artifact@v3
with:
name: changelog_bundle
- name: Setup Node for publishing to NPM
uses: actions/setup-node@v3
with:
node-version: 20
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Publish to NPM
run: |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.yarnpkg.com"
yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Github-Package-Registry-Node:
name: Publishing release to Github Package Registry
runs-on: ubuntu-latest
if: >-
!(contains(github.event.head_commit.message, '[skip publish]')
||github.event.inputs.skip-publish == true)
needs: GitHubCreateTag
steps:
- name: Checkout Project
uses: actions/checkout@v3
- name: Setup Node for publishing to Github
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: 'https://npm.pkg.github.com'
scope: '@favware'
cache: yarn
- name: Download generated typings artifact
uses: actions/download-artifact@v3
with:
name: typescript_bundle
path: dist/
- name: Download stored package.json
uses: actions/download-artifact@v3
with:
name: package_bundle
- name: Download stored changelog.md
uses: actions/download-artifact@v3
with:
name: changelog_bundle
- name: Install Dependencies
run: yarn --immutable
- name: Publish to Github
run: |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://npm.pkg.github.com"
yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}