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.
114 lines
3.2 KiB
114 lines
3.2 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: Disable dev flag
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
sudo apt-get install jq -y
|
|
mv package.json pkg-temp.json
|
|
jq -r '.dev |= false' pkg-temp.json > package.json
|
|
rm pkg-temp.json
|
|
|
|
- name: Set Package Version (tag)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
mv package.json pkg-temp.json
|
|
jq -r '.version |= "${{ steps.meta_tag.outputs.version }}"' pkg-temp.json > package.json
|
|
rm pkg-temp.json
|
|
cat package.json
|
|
|
|
- name: Set Package Version (bleeding)
|
|
if: false == startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
mv package.json pkg-temp.json
|
|
jq -r '.version |= "${{ steps.meta_bleeding.outputs.version }}"' pkg-temp.json > package.json
|
|
rm pkg-temp.json
|
|
cat package.json
|
|
|
|
- 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 }}
|