Some checks failed
Build and Push Docker Image / build (push) Failing after 0s
55 lines
1.3 KiB
YAML
55 lines
1.3 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
DOCKER_TLS_CERTDIR: /certs
|
|
RAILS_ENV: production
|
|
# GitHub/Forgejo equivalent of CI_REGISTRY_IMAGE + commit refs
|
|
CONTAINER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.ref_name }}-${{ github.sha }}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker
|
|
|
|
services:
|
|
docker:
|
|
image: docker:20.10.16-dind
|
|
options: --privileged
|
|
ports:
|
|
- 2375:2375
|
|
env:
|
|
DOCKER_TLS_CERTDIR: /certs
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker CLI
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Docker info
|
|
run: docker info
|
|
|
|
- name: Log in to container registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login \
|
|
-u "${{ secrets.REGISTRY_USER }}" \
|
|
--password-stdin \
|
|
${{ secrets.REGISTRY_URL }}
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build -t "$CONTAINER_IMAGE" .
|
|
docker tag "$CONTAINER_IMAGE" "${{ secrets.REGISTRY_IMAGE }}:latest"
|
|
|
|
- name: Push Docker images
|
|
run: |
|
|
docker push "$CONTAINER_IMAGE"
|
|
docker push "${{ secrets.REGISTRY_IMAGE }}:latest"
|