Build Docker images #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Verify and Build | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
test-and-build: | |
name: Build application | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run linter | |
run: npm run lint | |
- name: Generate static application | |
run: npm run generate | |
- name: Upload application | |
uses: actions/upload-artifact@v3 | |
with: | |
name: static | |
path: .output/public/ | |
if-no-files-found: error | |
- name: Generate SSR application | |
run: npm run build | |
- name: Upload application | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ssr | |
path: .output/ | |
if-no-files-found: error | |
release: | |
name: Release application | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download static application | |
uses: actions/download-artifact@v3 | |
with: | |
name: static | |
path: static | |
- name: Bundle application | |
working-directory: static | |
run: tar -czf ../minisites.tgz ./* | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
files: minisites.tgz | |
generate_release_notes: true | |
- name: Download SSR application | |
uses: actions/download-artifact@v3 | |
with: | |
name: ssr | |
path: .output | |
- name: Determine version tag | |
id: version | |
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | |
- name: Build Docker image | |
uses: docker/build-push-action@v2 | |
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' | |
with: | |
context: app | |
file: Dockerfile | |
push: true | |
tags: | | |
${{ github.repository }}:latest | |
${{ github.repository }}:${{ github.ref }} | |
${{ github.repository }}:${{ steps.version.outputs.tag }} |