mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.2 KiB
115 lines
3.2 KiB
name: docker-build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- tyclipso
|
|
|
|
tags:
|
|
- v*
|
|
|
|
# Run tests for any PRs.
|
|
pull_request:
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
|
|
jobs:
|
|
# Test building the docker image on pull requests
|
|
test-build:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Build image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: false
|
|
context: .
|
|
file: dev/build/Dockerfile
|
|
|
|
# Build image and push image to GitHub Packages.
|
|
# See also https://docs.docker.com/docker-hub/builds/
|
|
build-and-push-image:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push'
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v3
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ github.repository }}
|
|
tags: |
|
|
type=ref,event=tag,priority=400
|
|
type=sha,prefix=,priority=200
|
|
type=edge,priority=100
|
|
|
|
- name: Get build time
|
|
uses: gerred/actions/current-time@master
|
|
id: build_time
|
|
|
|
- name: Rewrite entries in package.json to match repository
|
|
uses: microsoft/variable-substitution@v1
|
|
with:
|
|
files: "package.json"
|
|
env:
|
|
version: ${{ steps.meta.outputs.version }}
|
|
releaseDate: ${{ steps.build_time.outputs.time }}
|
|
repository.url: "git+${{ github.server_url }}/${{ github.repository }}.git"
|
|
bugs.url: "${{ github.server_url }}/${{ github.repository }}/issues"
|
|
homepage: "${{ github.server_url }}/${{ github.repository }}#readme"
|
|
|
|
- name: Build and push Docker image on branch
|
|
if: false == startsWith(github.ref, 'refs/tags/v')
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
context: .
|
|
file: dev/build/Dockerfile
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Extract metadata for Docker for tag
|
|
id: metatag
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: docker/metadata-action@v3
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ github.repository }}
|
|
tags: |
|
|
type=ref,event=tag
|
|
|
|
- name: Set dev flag to false in package.json for tag
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: microsoft/variable-substitution@v1
|
|
with:
|
|
files: "package.json"
|
|
env:
|
|
dev: "false"
|
|
|
|
- name: Build and push Docker image for tag
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
context: .
|
|
file: dev/build/Dockerfile
|
|
tags: ${{ steps.metatag.outputs.tags }}
|
|
labels: ${{ steps.metatag.outputs.labels }}
|