Skip to content
Merged
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
179 changes: 3 additions & 176 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ jobs:
uses: actions/github-script@v8
with:
script: |
const workflowRun = context.payload.workflow_run;
const headBranch = workflowRun?.head_branch;
if (typeof headBranch === 'string' && headBranch.startsWith('hotfix/')) {
core.info('hotfix/* branch detected; skipping CI job verification.');
return;
}

const runId = workflowRun.id;
const runId = context.payload.workflow_run.id;
const requiredJobs = ['Lint', 'Unit Tests'];
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
Expand Down Expand Up @@ -60,133 +53,24 @@ jobs:
github.event.workflow_run.event == 'pull_request'

steps:
- name: Hotfix branch — skip preview deploy
if: ${{ startsWith(github.event.workflow_run.head_branch, 'hotfix/') }}
run: |
echo "hotfix/* branch detected; skipping preview deployment (treat as success)."

- name: Checkout repository
if: ${{ !startsWith(github.event.workflow_run.head_branch, 'hotfix/') }}
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}

- name: Create GitHub deployment (Preview)
if: ${{ !startsWith(github.event.workflow_run.head_branch, 'hotfix/') }}
id: github-deployment-preview
uses: actions/github-script@v8
with:
script: |
const workflowRun = context.payload.workflow_run;
const ref = workflowRun?.head_sha;
if (!ref) {
core.setFailed('Missing workflow_run.head_sha; cannot create GitHub deployment.');
return;
}

const { data } = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref,
auto_merge: false,
required_contexts: [],
environment: 'vercel-preview',
transient_environment: true,
production_environment: false,
description: 'Vercel preview deployment'
});

core.setOutput('deployment_id', String(data.id));

- name: Deploy to Vercel (Preview)
if: ${{ !startsWith(github.event.workflow_run.head_branch, 'hotfix/') }}
uses: amondnet/vercel-action@v41.1.4
id: vercel-preview
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
github-comment: false
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
GITHUB_SHA: ${{ github.event.workflow_run.head_sha }}
GITHUB_REF: refs/heads/${{ github.event.workflow_run.head_branch }}

- name: Update GitHub deployment status (Preview)
if: ${{ !startsWith(github.event.workflow_run.head_branch, 'hotfix/') && always() }}
uses: actions/github-script@v8
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
with:
script: |
const deploymentIdRaw = '${{ steps.github-deployment-preview.outputs.deployment_id }}';
const deploymentId = Number(deploymentIdRaw);
if (!deploymentIdRaw || Number.isNaN(deploymentId)) {
core.warning('Missing deployment id; skipping GitHub deployment status update.');
return;
}

const workflowRun = context.payload.workflow_run;
const rawPreviewUrl = '${{ steps.vercel-preview.outputs.preview-url }}'.trim();
const isVercelUrl = (url) => typeof url === 'string' && /vercel\.(app|com)/.test(url);
const fallbackRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;

const fetchDeploymentUrl = async () => {
if (!process.env.VERCEL_TOKEN || !process.env.VERCEL_PROJECT_ID) {
return null;
}
if (typeof fetch !== 'function') {
return null;
}
const query = new URLSearchParams({
projectId: process.env.VERCEL_PROJECT_ID,
'meta-githubCommitSha': workflowRun?.head_sha ?? '',
limit: '1'
});
if (process.env.VERCEL_ORG_ID) {
query.set('teamId', process.env.VERCEL_ORG_ID);
}
const response = await fetch(`https://api.vercel.com/v6/deployments?${query.toString()}`, {
headers: {
Authorization: `Bearer ${process.env.VERCEL_TOKEN}`
}
});
if (!response.ok) {
return null;
}
const data = await response.json();
const deployment = data?.deployments?.[0];
if (deployment?.url) {
return `https://${deployment.url}`;
}
if (deployment?.inspectorUrl) {
return deployment.inspectorUrl.startsWith('http')
? deployment.inspectorUrl
: `https://${deployment.inspectorUrl}`;
}
return null;
};

const previewUrl = isVercelUrl(rawPreviewUrl) ? rawPreviewUrl : await fetchDeploymentUrl();
const state = '${{ steps.vercel-preview.outcome }}' === 'success' ? 'success' : 'failure';
const targetUrl = isVercelUrl(previewUrl) ? previewUrl : fallbackRunUrl;

await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deploymentId,
state,
environment: 'vercel-preview',
environment_url: targetUrl,
log_url: fallbackRunUrl,
description: state === 'success' ? 'Vercel preview is ready' : 'Vercel preview failed'
});

- name: Comment preview URL on PR
if: ${{ !startsWith(github.event.workflow_run.head_branch, 'hotfix/') && always() && steps.vercel-preview.outcome == 'success' }}
if: always() && steps.vercel-preview.outcome == 'success'
uses: actions/github-script@v8
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
Expand Down Expand Up @@ -301,7 +185,7 @@ jobs:
}

- name: Comment preview failure on PR
if: ${{ !startsWith(github.event.workflow_run.head_branch, 'hotfix/') && always() && steps.vercel-preview.outcome != 'success' }}
if: always() && steps.vercel-preview.outcome != 'success'
uses: actions/github-script@v8
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
Expand Down Expand Up @@ -389,73 +273,16 @@ jobs:
with:
ref: ${{ github.event.workflow_run.head_sha }}

- name: Create GitHub deployment (Production)
id: github-deployment-production
uses: actions/github-script@v8
with:
script: |
const workflowRun = context.payload.workflow_run;
const ref = workflowRun?.head_sha;
if (!ref) {
core.setFailed('Missing workflow_run.head_sha; cannot create GitHub deployment.');
return;
}

const { data } = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref,
auto_merge: false,
required_contexts: [],
environment: 'production',
transient_environment: false,
production_environment: true,
description: 'Vercel production deployment'
});

core.setOutput('deployment_id', String(data.id));

- name: Deploy to Vercel (Production)
uses: amondnet/vercel-action@v41.1.4
id: vercel-production
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-args: '--prod'
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
GITHUB_SHA: ${{ github.event.workflow_run.head_sha }}
GITHUB_REF: refs/heads/${{ github.event.workflow_run.head_branch }}

- name: Update GitHub deployment status (Production)
if: ${{ always() }}
uses: actions/github-script@v8
with:
script: |
const deploymentIdRaw = '${{ steps.github-deployment-production.outputs.deployment_id }}';
const deploymentId = Number(deploymentIdRaw);
if (!deploymentIdRaw || Number.isNaN(deploymentId)) {
core.warning('Missing deployment id; skipping GitHub deployment status update.');
return;
}

const state = '${{ steps.vercel-production.outcome }}' === 'success' ? 'success' : 'failure';
const rawUrl = '${{ steps.vercel-production.outputs.preview-url }}'.trim();
const environmentUrl = rawUrl ? rawUrl : undefined;
const logUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;

await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deploymentId,
state,
environment: 'production',
environment_url: environmentUrl,
log_url: logUrl,
description: state === 'success' ? 'Production deploy completed' : 'Production deploy failed'
});

- name: Log production deployment
if: always() && steps.vercel-production.outcome == 'success'
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"Neue",
"Niklas",
"noabbr",
"Noto",
"octocat",
"oden",
"oembed",
Expand All @@ -90,6 +91,7 @@
"repost",
"reposts",
"RGAA",
"Roboto",
"rodgtr",
"Ryuk",
"samp",
Expand Down
20 changes: 0 additions & 20 deletions _TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,6 @@ Adds some custom directives:
1. Add `rel="prefetch"` to any `<a />` tags to prefetch when visible
2. Add `rel="prefetch-intent"` to any `<a />` links on your page to prefetch them only when they are hovered over, touched, or focused.

### [astro-webfinger](https://www.npmjs.com/package/astro-webfinger)

Allows any Mastodon instance to discover your Mastodon profile directly from your own domain.


## Refactor social networks in Authors collection to Contact collection format

The contact data collection uses an array of social networks, with keys:

```
{
network: z.string(),
name: z.string(),
url: z.string().url(),
order: z.number(),
}
```

The authors collection is using named entries under a "social" property, like "twitter", "github", etc. This task is to refactor that to use an array like contact data collection. We also need to add a color for the social network icon, or some other approach to setting the color of it while enabling theming.

## Stuff from ZMarkdown, a prepackaged Unified config

Repo is in root of Corporate Websites
Expand Down
6 changes: 5 additions & 1 deletion src/components/scripts/utils/environmentClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
* This file cannot be used in API endpoint code. See
* src/lib/config/environmentServer.ts for details.
*/
import { PACKAGE_RELEASE_VERSION, PRIVACY_POLICY_VERSION, PUBLIC_GOOGLE_MAPS_API_KEY } from 'astro:env/client'
import {
PACKAGE_RELEASE_VERSION,
PRIVACY_POLICY_VERSION,
PUBLIC_GOOGLE_MAPS_API_KEY
} from 'astro:env/client'
import { ClientScriptError } from '@components/scripts/errors'

/**
Expand Down
34 changes: 12 additions & 22 deletions src/content.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ const createBaseCollectionSchema = ({ image }: SchemaContext) =>
tags: z.array(z.enum(validTags)),
})

const createSocialCollectionSchema = () =>
z.array(
z.object({
network: z.string(),
name: z.string(),
url: z.string().url(),
order: z.number(),
}),
)

/**
* =================================================================================
*
Expand Down Expand Up @@ -170,20 +180,7 @@ const authorsCollection = defineCollection({
name: z.string(),
email: z.string().email(),
avatar: z.string(),
social: z.object({
twitter: z.object({
name: z.string(),
url: z.string().url(),
}),
github: z.object({
name: z.string(),
url: z.string().url(),
}),
linkedin: z.object({
name: z.string(),
url: z.string().url(),
}),
}),
social: createSocialCollectionSchema(),
}),
})

Expand All @@ -202,14 +199,7 @@ const contactDataCollection = defineCollection({
telephoneLocal: z.string(),
telephoneMobile: z.string(),
telephoneTollFree: z.string(),
social: z.array(
z.object({
network: z.string(),
name: z.string(),
url: z.string().url(),
order: z.number(),
}),
),
social: createSocialCollectionSchema(),
}),
})

Expand Down
21 changes: 18 additions & 3 deletions src/content/authors/kevin-brown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@ name: "Kevin Brown"
email: "kevin@webstackbuilders.com"
avatar: "/images/avatars/kevin-brown.webp"
social:
twitter:
- network: "x"
name: "WebstackDev"
url: "https://x.com/WebstackDev"
github:
order: 1
- network: "github"
name: "webstackdev"
url: "https://github.com/webstackdev"
linkedin:
order: 2
- network: "linkedin"
name: "kevin-brown-developer"
url: "https://www.linkedin.com/in/kevin-brown-developer/"
order: 3
- network: "codepen"
name: "WebstackDev"
url: "https://codepen.io/webstackdev"
order: 4
- network: "bluesky"
name: "webstackdev.bsky.social"
url: "https://bsky.app/profile/webstackdev.bsky.social"
order: 5
- network: "mastodon"
name: "@webstackdev"
url: "https://k8s.social/@webstackdev"
order: 6
---
Loading