Skip to content

Build

Build #86

Workflow file for this run

name: Build
on:
schedule:
- cron: "0 5 * * 1"
workflow_call:
workflow_dispatch:
jobs:
build-image:
name: Build images and push to registry
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Create new buildx builder
uses: docker/setup-buildx-action@v2
- name: Generate app image tags
uses: docker/metadata-action@v4
id: meta-app
with:
bake-target: app
images: |
ghcr.io/${{ github.repository }}-app
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
- name: Generate web image tags
uses: docker/metadata-action@v4
id: meta-web
with:
bake-target: web
images: |
ghcr.io/${{ github.repository }}-web
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
- name: Generate cache tag for app image
uses: docker/metadata-action@v4
id: cache-tag-app
with:
images: |
ghcr.io/${{ github.repository }}-app
tags: |
type=ref,event=branch
type=raw,enable=${{ github.ref_type == 'tag' }},value=${{ github.event.repository.default_branch }}
flavor:
suffix=-cache
- name: Generate cache tag for web image
uses: docker/metadata-action@v4
id: cache-tag-web
with:
images: |
ghcr.io/${{ github.repository }}-web
tags: |
type=ref,event=branch
type=raw,enable=${{ github.ref_type == 'tag' }},value=${{ github.event.repository.default_branch }}
flavor:
suffix=-cache
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/bake-action@v2.3.0
with:
targets: release
files: |
./docker-bake.hcl
${{ steps.meta-app.outputs.bake-file }}
${{ steps.meta-web.outputs.bake-file }}
set: |
*.platform=linux/amd64
app.cache-from=type=registry,ref=${{ steps.cache-tag-app.outputs.tags }}
app.cache-to=type=registry,ref=${{ steps.cache-tag-app.outputs.tags }},mode=max
web.cache-from=type=registry,ref=${{ steps.cache-tag-web.outputs.tags }}
web.cache-to=type=registry,ref=${{ steps.cache-tag-web.outputs.tags }},mode=max
push: true
build-deploy:
name: Build NS8 deploy image
runs-on: ubuntu-22.04
needs: build-image
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Generate tags
uses: docker/metadata-action@v4
id: meta
with:
images: |
ghcr.io/nethserver/ns8-phonehome
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Generate Phonehome image tags
uses: docker/metadata-action@v4
id: phonehome-tags
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image with buildah
env:
TAGS: ${{ steps.meta.outputs.tags }}
LABELS: ${{ steps.meta.outputs.labels }}
ARGS: |
PHONEHOME_TAG=${{ steps.phonehome-tags.outputs.version }}
PHONEHOME_SERVER_APP=${{ steps.phonehome-tags.outputs.tags }}-app
PHONEHOME_SERVER_WEB=${{ steps.phonehome-tags.outputs.tags }}-web
working-directory: deploy/ns8
run: |
./build-images.sh
- name: Push image to registry
run: |
PUSH_TAGS='${{ steps.meta.outputs.tags }}'
for tag in $PUSH_TAGS; do
podman push "$tag"
done