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.
wiki/.github/workflows/docker.yml

121 lines
3.4 KiB

name: docker-build
on:
push:
branches:
- tyclipso
tags:
- v*
# Run tests for any PRs.
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
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 (tag)
id: meta_tag
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
- name: Extract metadata for Docker (bleeding)
id: meta_bleeding
if: false == startsWith(github.ref, 'refs/tags/v')
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
- name: Get build time
uses: gerred/actions/current-time@master
id: build_time
- name: Rewrite entries in package.json to repository
uses: microsoft/variable-substitution@v1
with:
files: "package.json"
env:
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: Disable dev flag and set package version (tag)
if: startsWith(github.ref, 'refs/tags/v')
uses: microsoft/variable-substitution@v1
with:
files: "package.json"
env:
dev: "false"
version: ${{ steps.meta_tag.outputs.version }}
- name: Set package version (bleeding)
if: false == startsWith(github.ref, 'refs/tags/v')
uses: microsoft/variable-substitution@v1
with:
files: "package.json"
env:
version: ${{ steps.meta_bleeding.outputs.version }}
- name: Build and push Docker image (tag)
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v2
with:
push: true
context: .
file: dev/build/Dockerfile
tags: ${{ steps.meta_tag.outputs.tags }}
- name: Build and push Docker image (bleeding)
if: false == startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v2
with:
push: true
context: .
file: dev/build/Dockerfile
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:bleeding,${{ steps.meta_bleeding.outputs.tags }}