first pass of continuous integration
This commit is contained in:
107
.github/workflows/build.yaml
vendored
Normal file
107
.github/workflows/build.yaml
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
name: Build and Release Docker Images
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: scm.wyattjmiller.com
|
||||
IMAGE_PREFIX: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- dockerfile: Dockerfile
|
||||
image: mywebsite-public
|
||||
context: ./backend/public
|
||||
- dockerfile: Dockerfile
|
||||
image: mywebsite-task
|
||||
context: ./backend/task
|
||||
- dockerfile: Dockerfile
|
||||
image: mywebsite-frontend
|
||||
context: ./frontend
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.GH_ACTION_USERNAME }}
|
||||
password: ${{ secrets.GH_ACTION_TOKEN }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ matrix.image }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ${{ matrix.context }}
|
||||
file: ${{ matrix.context }}/${{ matrix.dockerfile }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
platforms: linux/amd64
|
||||
|
||||
create-release:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
needs: build-and-push
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Create Release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_ACTION_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
release_name: Release ${{ github.ref_name }}
|
||||
body: |
|
||||
## Docker Images Released
|
||||
|
||||
The following Docker images have been built and pushed to the container registry:
|
||||
|
||||
- `${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/mywebsite-public:${{ github.ref_name }}`
|
||||
- `${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/mywebsite-task:${{ github.ref_name }}`
|
||||
- `${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/mywebsite-frontend:${{ github.ref_name }}`
|
||||
|
||||
### Usage
|
||||
```bash
|
||||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/mywebsite-public:${{ github.ref_name }}
|
||||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/mywebsite-task:${{ github.ref_name }}
|
||||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/mywebsite-frontend:${{ github.ref_name }}
|
||||
```
|
||||
draft: false
|
||||
prerelease: false
|
Reference in New Issue
Block a user