96 lines
3.1 KiB
YAML
96 lines
3.1 KiB
YAML
name: Container Build and Publish
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
REGISTRY: gitea.coracle.social
|
|
|
|
jobs:
|
|
build-and-push-image:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Set Variables
|
|
id: set_variables
|
|
run: |
|
|
# convert everything to lowercase because ghcr repository name must be lowercase
|
|
ACTOR="${GITHUB_ACTOR,,}"
|
|
REPOSITORY="${GITHUB_REPOSITORY##*/}"
|
|
REPOSITORY="${REPOSITORY,,}"
|
|
echo "actor=${ACTOR}" >> $GITHUB_OUTPUT
|
|
echo "repository=${REPOSITORY}" >> $GITHUB_OUTPUT
|
|
shell: bash
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver: docker-container
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.PACKAGE_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for nodejs image
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ steps.set_variables.outputs.actor }}/${{ steps.set_variables.outputs.repository }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,prefix={{branch}}-
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
|
|
- name: Build and push nodejs-based image
|
|
id: push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Containerfile
|
|
push: true
|
|
target: production-nodejs
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
#cache-from: type=gha
|
|
#cache-to: type=gha,mode=max
|
|
|
|
#- name: Extract metadata (tags, labels) for nginx image
|
|
# id: meta
|
|
# uses: docker/metadata-action@v5
|
|
# with:
|
|
# images: ${{ env.REGISTRY }}/${{ steps.set_variables.outputs.actor }}/${{ steps.set_variables.outputs.repository }}-nginx
|
|
# tags: |
|
|
# type=ref,event=branch
|
|
# type=semver,pattern={{version}}
|
|
# type=semver,pattern={{major}}.{{minor}}
|
|
# type=sha,prefix={{branch}}-
|
|
# type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
|
|
#- name: Build and push nginx-based image
|
|
# id: push
|
|
# uses: docker/build-push-action@v5
|
|
# with:
|
|
# context: .
|
|
# file: ./Containerfile
|
|
# push: true
|
|
# target: production-nginx
|
|
# platforms: linux/amd64,linux/arm64
|
|
# tags: ${{ steps.meta.outputs.tags }}
|
|
# labels: ${{ steps.meta.outputs.labels }}
|
|
# cache-from: type=gha
|
|
# cache-to: type=gha,mode=max
|