Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge preview into main #55

Merged
merged 6 commits into from
May 17, 2023
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
102 changes: 102 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Build & Publish

on:
push:
branches:
- "main"
- "preview"

env:
REGISTRY: ghcr.io
IMAGE_NAME: "ghcr.io/${{ github.repository }}"

jobs:
build:
runs-on: ubuntu-latest

permissions:
packages: write

steps:
- uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}

- name: Build and Push Docker Image for Local Dev
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: "${{ env.IMAGE_NAME }}:latest"
platforms: linux/amd64

- name: Build Docker Image(devl)
if: github.ref == 'refs/heads/preview'
uses: docker/build-push-action@v4
with:
context: .
push: false
tags: "${{ env.IMAGE_NAME }}:latest"
platforms: linux/amd64
build-args: |
configfile=_config-dev.yml

- name: Build Docker Image (prod)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v4
with:
context: .
push: false
tags: "${{ env.IMAGE_NAME }}:latest"
platforms: linux/amd64
build-args: |
configfile=_config-production.yml

- name: Extract build artifact from docker image
uses: shrink/actions-docker-extract@v2
id: extract
with:
image: "${{ env.IMAGE_NAME }}:latest"
path: /usr/share/nginx/html/

- name: Archive build artifact
run: tar czvf dist.tar.gz -C ${{ steps.extract.outputs.destination }}/html .

- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
path: ./dist.tar.gz
name: dist

release:
needs: build
uses: chnm/.github/.github/workflows/create-release.yml@main
secrets: inherit
with:
github-run-id: "${{ github.run_id }}"
github-workflow: "${{ github.workflow }}"
github-workflow-ref: "${{ github.workflow_ref }}"
github-workflow-sha: "${{ github.workflow_sha }}"
github-workspace: "${{ github.workspace }}"
github-repository: "${{ github.repository }}"
github-repository-owner: "${{ github.repository_owner }}"
github-repository-name: "${{ github.event.repository.name }}"
github-repository-url: "${{ github.repository-url }}"
github-action-ref: "${{ github.action_ref }}"
github-event-name: "${{ github.event_name }}"
github-actor: "${{ github.actor }}"
github-triggering-actor: "${{ github.triggering_actor }}"
github-base-ref: "${{ github.base_ref }}"
github-ref-name: "${{ github.ref_name }}"
github-ref-type: "${{ github.ref_type }}"
github-ref: "${{ github.ref }}"
github-sha: "${{ github.sha }}"
build-artifact-name: "dist"
release-artifact-tarball-filename: "dist.tar.gz"
release-tag-name-type: "iso"

15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ruby:3.1.2 as build-stage

ARG configfile
ENV CONFIG_FILE $configfile

WORKDIR /app
ADD . .

RUN gem install bundler
RUN bundle install
RUN bundle exec jekyll build --destination ./_site --config _config.yml,${CONFIG_FILE}

FROM nginx:1.23-alpine

COPY --from=build-stage /app/_site/ /usr/share/nginx/html
19 changes: 1 addition & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,4 @@ preview : clean
clean :
rm -rf _site/*

deploy : clean
@echo "Building development site ..."
bundle exec jekyll build --config _config.yml,_config-dev.yml
@echo "Deploying to dev server ..."
rsync --delete --exclude appendices/ --exclude dev/ --exclude crdh.code-workspace \
--itemize-changes --omit-dir-times --checksum --no-perms -avz \
_site/* kaizen:/websites/crdh/www/dev/ | egrep -v '^\.'


deploy-production : clean
@echo "Building site ..."
bundle exec jekyll build --config _config.yml,_config-production.yml
@echo "Deploying to server ..."
rsync --delete --exclude appendices/ --exclude dev/ --exclude crdh.code-workspace \
--itemize-changes --omit-dir-times --checksum --no-perms -avz \
_site/* kaizen:/websites/crdh/www/ | egrep -v '^\.'

.PHONY: preview deploy deploy-production clean
.PHONY: preview clean
2 changes: 1 addition & 1 deletion _config-dev.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
url: "https://crdh.rrchnm.org/dev"
url: "https://dev.crdh.rrchnm.org"
future: true
Loading