Skip to content

Crea pre

Crea pre #24

Workflow file for this run

name: Continuous Integration
env:
DOCKER_BUILDKIT: 1
on:
push:
branches:
- main
pull_request:
jobs:
generate-ref:
name: Generate Ref
runs-on: ubuntu-latest
outputs:
REF: ${{ steps.generate-ref.outputs.ref }}
steps:
- uses: actions/checkout@v4
- id: generate-ref
name: Generate Ref
run: |
if [ "${{ github.event_name }}" == "pull_request" ] ; then
ref=$(php -r "echo str_replace('/', '-SLASH-', '${{ github.event.pull_request.head.ref }}');")
echo "$ref"
printf "::set-output name=ref::%s" $ref
exit 0
fi
echo "${GITHUB_REF##*/}"
echo "::set-output name=ref::${GITHUB_REF##*/}"
lint-dockerfile:
name: Lint Dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint Dockerfile
uses: docker://hadolint/hadolint:latest-debian
with:
entrypoint: hadolint
args: Dockerfile
build-docker-image:
name: Build Docker image
needs:
- generate-ref
- lint-dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: mkdir ./docker-image/
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- run: docker version
- run: docker images
env:
REF: ${{ needs.generate-ref.outputs.ref }}
- name: Login to GitHub Container Registry
if: github.actor != 'dependabot[bot]'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | \
docker login ghcr.io \
--username "${GITHUB_ACTOR}" \
--password-stdin
- run: docker build --platform=linux/arm64,linux/amd64 --output=type=registry --no-cache -t "$(echo "ghcr.io/${GITHUB_REPOSITORY}:${{ needs.generate-ref.outputs.ref }}" | tr '[:upper:]' '[:lower:]')" ./ -f Dockerfile --target=runtime
- run: |
printf "FROM %s" $(echo "ghcr.io/${GITHUB_REPOSITORY}:${{ needs.generate-ref.outputs.ref }}" | tr '[:upper:]' '[:lower:]') >> Dockerfile.tag
docker build --platform=linux/arm64,linux/amd64 --output=type=registry --no-cache -f Dockerfile.tag -t $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]') .
- run: docker images