Skip to content
Open
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
23 changes: 23 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,32 @@ permissions:
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate files
run: |
echo "Validating CV website files..."
if [ ! -f "index.html" ]; then
echo "Error: index.html not found!"
exit 1
fi
echo "✓ index.html found"
if [ ! -f "print.css" ]; then
echo "Warning: print.css not found"
else
echo "✓ print.css found"
fi
echo "✓ Build validation complete"

deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/sync-to-gitlab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Sync to GitLab

on:
push:
branches:
- main
- style-updates
- deployment-development
tags:
- '*'

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper syncing

- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"

- name: Add GitLab remote
run: |
git remote add gitlab git@hill-st.nohost.me:pwflint/CV.git || true
git remote set-url gitlab git@hill-st.nohost.me:pwflint/CV.git

- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.GITLAB_SSH_PRIVATE_KEY }}

- name: Push to GitLab
run: |
git push gitlab ${GITHUB_REF#refs/heads/} || true
# If pushing main, also try to update other branches if they exist
if [ "${GITHUB_REF#refs/heads/}" = "main" ]; then
git push gitlab main || true
fi
96 changes: 93 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,99 @@
# GitLab CI/CD Pipeline for CV Website Deployment
# NOTE: This repository uses GitHub Pages for deployment via GitHub Actions
# This GitLab CI/CD configuration is provided as an alternative option
# if you want to deploy to GitLab Pages instead
#
# Primary deployment: GitHub Pages (see .github/workflows/pages.yml)
# Alternative deployment: GitLab Pages (this file)

stages:
- build
- deploy
- sync

variables:
DEPLOY_BRANCH: "main"
PUBLIC_DIR: "."

# Build stage - validate HTML/CSS if needed
build:
stage: build
image: node:18-alpine
script:
- echo "Building CV website..."
- |
if [ ! -f "index.html" ]; then
echo "Error: index.html not found!"
exit 1
fi
echo "✓ index.html found"
if [ ! -f "print.css" ]; then
echo "Warning: print.css not found"
else
echo "✓ print.css found"
fi
echo "✓ Build validation complete"
artifacts:
paths:
- index.html
- print.css
- "*.JPG"
- "*.jpg"
- "*.png"
expire_in: 1 hour
only:
- main
- master
- merge_requests

# Deploy to GitLab Pages
pages:
stage: deploy
image: alpine:latest
script:
- cp -r * .public
- echo "Deploying to GitLab Pages..."
- |
# Copy all necessary files to public directory
mkdir -p public
cp -r index.html print.css public/ 2>/dev/null || true
# Copy images
cp -r *.JPG *.jpg *.png public/ 2>/dev/null || true
# Copy any other assets
if [ -d "assets" ]; then
cp -r assets public/ 2>/dev/null || true
fi
- echo "✓ Files copied to public directory"
- echo "Deployment complete! Site will be available at:"
- echo "https://$CI_PROJECT_NAMESPACE.gitlab.io/$CI_PROJECT_NAME"
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
only:
- main
- master

# Sync to GitHub (for when GitLab becomes primary)
# This job will push changes to GitHub after successful deployment
# To enable: Uncomment and configure GITHUB_SSH_PRIVATE_KEY in GitLab CI/CD variables
# sync_to_github:
# stage: sync
# image: alpine:latest
# before_script:
# - apk add --no-cache git openssh-client
# - mkdir -p ~/.ssh
# - echo "$GITHUB_SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
# - chmod 600 ~/.ssh/id_rsa
# - ssh-keyscan github.com >> ~/.ssh/known_hosts
# - eval $(ssh-agent -s)
# - ssh-add ~/.ssh/id_rsa
# script:
# - git config user.name "GitLab CI"
# - git config user.email "gitlab-ci@noreply.gitlab.com"
# - git remote add github git@github.com:pwflint/CV.git || true
# - git remote set-url github git@github.com:pwflint/CV.git
# - git push github ${CI_COMMIT_REF_NAME} || echo "Push to GitHub failed (non-critical)"
# only:
# - main
# - master
# when: on_success
# allow_failure: true
138 changes: 138 additions & 0 deletions DEPLOYMENT_MIGRATION_PLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Deployment Migration Plan: GitHub → GitLab

## Current State

### Primary Repository: GitHub (origin)
- **Deployment**: GitHub Pages via GitHub Actions
- **Workflow**: `.github/workflows/pages.yml`
- **Sync**: Manual push to GitLab (hill-st) when needed
- **Auto-sync**: `.github/workflows/sync-to-gitlab.yml` (to be configured)

### Secondary Repository: GitLab (hill-st)
- **Deployment**: GitLab Pages (configured but not primary)
- **Workflow**: `.gitlab-ci.yml` (alternative deployment option)
- **Status**: Protected main branch, receives syncs from GitHub

## Migration Goal

Switch primary deployment to GitLab Pages, making:
- **GitLab (hill-st)** → Primary repository and deployment
- **GitHub (origin)** → Backup/sync repository

## Steps Required

### 1. Update GitLab CI/CD Configuration
- [ ] Review and finalize `.gitlab-ci.yml` for GitLab Pages deployment
- [ ] Ensure build and deploy stages are properly configured
- [ ] Test GitLab Pages deployment on a feature branch
- [ ] Verify all assets (images, CSS, JS) deploy correctly

### 2. Update Remote Configuration
- [ ] Change local git remotes:
```bash
git remote rename origin github-backup
git remote rename hill-st origin
```
- [ ] Update branch tracking to point to new origin (GitLab)
- [ ] Verify remote configuration: `git remote -v`

### 3. Reverse Sync Workflow
- [ ] Create new workflow: `.gitlab-ci.yml` sync job (or separate pipeline)
- [ ] Set up GitLab CI/CD to push to GitHub on successful deployments
- [ ] Configure GitHub personal access token or deploy key as GitLab CI/CD variable
- [ ] Test sync from GitLab → GitHub

### 4. Update Documentation
- [ ] Update `README.md` to reflect GitLab as primary deployment
- [ ] Update deployment instructions
- [ ] Document new workflow (GitLab → GitHub sync)
- [ ] Update any references to GitHub Pages

### 5. GitHub Actions Cleanup
- [ ] Remove or disable `.github/workflows/sync-to-gitlab.yml` (no longer needed)
- [ ] Keep `.github/workflows/pages.yml` for reference or remove if not needed
- [ ] Consider archiving GitHub Pages deployment workflow

### 6. GitLab Pages Configuration
- [ ] Enable GitLab Pages in repository settings
- [ ] Configure custom domain (if applicable)
- [ ] Set up SSL/TLS certificate
- [ ] Test deployment and verify site is accessible

### 7. Migration Execution
- [ ] Push current main branch to GitLab (if not already synced)
- [ ] Merge any pending PRs on GitHub first
- [ ] Create final sync from GitHub → GitLab
- [ ] Switch remotes locally
- [ ] Update any CI/CD variables or secrets
- [ ] Deploy to GitLab Pages
- [ ] Verify deployment works correctly

### 8. Post-Migration
- [ ] Update GitHub repository description/README to indicate it's a mirror
- [ ] Test the reverse sync (GitLab → GitHub)
- [ ] Monitor first few deployments to ensure sync works
- [ ] Update any external links/bookmarks to point to GitLab Pages URL

## GitLab CI/CD Sync Configuration

### Option A: Add sync job to existing `.gitlab-ci.yml`
```yaml
sync_to_github:
stage: deploy
image: alpine:latest
before_script:
- apk add --no-cache git openssh-client
- mkdir -p ~/.ssh
- echo "$GITHUB_SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan github.com >> ~/.ssh/known_hosts
script:
- git remote add github git@github.com:pwflint/CV.git || true
- git push github ${CI_COMMIT_REF_NAME} || true
only:
- main
when: on_success
```

### Option B: Separate sync pipeline
- Create dedicated sync job that runs after successful Pages deployment
- Use GitLab CI/CD variables for GitHub credentials
- Configure to run only on main branch deployments

## Considerations

### Branch Protection
- GitLab main branch is protected (cannot force push)
- Will need to use merge requests for all changes
- GitHub can remain less restricted as backup

### Deployment URLs
- Update any hardcoded URLs or references
- GitLab Pages URL format: `https://[namespace].gitlab.io/[project-name]`
- Or custom domain if configured

### Secrets Management
- Move GitHub-related secrets to GitLab CI/CD variables
- Set up GitHub personal access token or deploy key
- Store securely in GitLab's variable management

### Rollback Plan
- Keep GitHub Actions workflow files for quick rollback if needed
- Document how to switch back if issues arise
- Maintain ability to deploy from either platform during transition

## Timeline Recommendation

1. **Phase 1**: Set up and test GitLab Pages deployment (1-2 days)
2. **Phase 2**: Configure reverse sync workflow (1 day)
3. **Phase 3**: Update remotes and documentation (1 day)
4. **Phase 4**: Execute migration and verify (1 day)
5. **Phase 5**: Monitor and adjust (ongoing)

## Notes

- LICENSE file: Currently only on GitLab, should be added to GitHub during migration
- Current workflow files can be kept for reference
- Consider keeping both deployment methods active during transition period
- Test thoroughly before making GitLab the primary
Loading
Loading