Skip to content

Commit

Permalink
feat: migrate /circleci (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
amio authored Aug 8, 2023
1 parent 1c5b2c1 commit 0ca768c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion libs/badge-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const liveBadgeList = [
'wapm',
'snapcraft',
// CI
'circleci',
'appveyor',
'codacy',
'azure-pipelines',
Expand Down
2 changes: 2 additions & 0 deletions libs/badge-list2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import codeclimate from '../pages/api/codeclimate'
import codecov from '../pages/api/codecov'
import coveralls from '../pages/api/coveralls'
import travis from '../pages/api/travis'
import circleci from '../pages/api/circleci'
import chromeWebStore from '../pages/api/chrome-web-store'
import vsMarketplace from '../pages/api/vs-marketplace'
import openVsx from '../pages/api/open-vsx'
Expand Down Expand Up @@ -49,6 +50,7 @@ export default {
codecov: codecov.meta,
coveralls: coveralls.meta,
travis: travis.meta,
circleci: circleci.meta,
peertube: peertube.meta,
discord: discord.meta,
matrix: matrix.meta,
Expand Down
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const nextConfig = {
'/codecov',
'/coveralls',
'/travis',
'/circleci',
'/xo',
// social network
'/discord',
Expand Down
17 changes: 13 additions & 4 deletions api-/circleci.ts → pages/api/circleci.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import got from '../libs/got'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
import got from '../../libs/got'
import { createBadgenHandler, PathArgs } from '../../libs/create-badgen-handler-next'

const CIRCLECI_API_URL = 'https://circleci.com/api/v1.1/'

Expand All @@ -8,8 +8,8 @@ const client = got.extend({ prefixUrl: CIRCLECI_API_URL })
export default createBadgenHandler({
title: 'CircleCI',
examples: {
'/circleci/github/nuxt/nuxt.js': 'build',
'/circleci/github/nuxt/nuxt.js/master': 'build (branch)',
'/circleci/github/circleci/circleci-docs': 'build',
'/circleci/github/circleci/circleci-docs/master': 'build (branch)',
},
handlers: {
'/circleci/:vcs<github|gitlab>/:owner/:repo/:branch?': handler
Expand All @@ -23,6 +23,15 @@ async function handler ({ vcs, owner, repo, branch }: PathArgs) {
const searchParams = { filter: 'completed', limit: 1, shallow: true }
const [latest] = await client.get(path, { searchParams }).json<any>()


if (latest === undefined) {
return {
subject: 'circleci',
status: 'not found',
color: 'grey'
}
}

const color = {
failed: 'red',
success: 'green'
Expand Down
4 changes: 0 additions & 4 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"source": "/badgesize/:match*",
"destination": "https://v2022.badgen.net/badgesize/:match*"
},
{
"source": "/circleci/:match*",
"destination": "https://v2022.badgen.net/circleci/:match*"
},
{
"source": "/cocoapods/:match*",
"destination": "https://v2022.badgen.net/cocoapods/:match*"
Expand Down

2 comments on commit 0ca768c

@vercel
Copy link

@vercel vercel bot commented on 0ca768c Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ondasheroi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.