Update .forgejo/workflows/playing-around._yaml_
This commit is contained in:
parent
a88c156174
commit
8deed9ffd3
1 changed files with 47 additions and 56 deletions
|
|
@ -1,72 +1,63 @@
|
||||||
|
# =============================================================================
|
||||||
|
# Forgejo Actions workflow to build and push Docker image
|
||||||
|
# =============================================================================
|
||||||
|
# Triggered on push to main or master branches
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
name: Build and Push Docker Image
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches:
|
||||||
pull_request:
|
- main
|
||||||
branches: [main]
|
- master
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY_URL: registry.coolify1.workaround.org
|
|
||||||
# This creates: registry.coolify1.workaround.org/my-app:main-sha
|
|
||||||
CONTAINER_IMAGE: registry.coolify1.workaround.org/debshots:stage
|
|
||||||
RAILS_ENV: production
|
|
||||||
#CONTAINER_IMAGE: ${{ secrets.REGISTRY_IMAGE }}:${{ github.ref_name }}-${{ github.sha }}
|
|
||||||
DOCKER_HOST: tcp://localhost:2375
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-push-image:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
permissions:
|
||||||
image: node:22 # Optionally install Docker CLI in a step
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Check out repository code
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Podman
|
# -------------------------------------------------------------------------
|
||||||
|
# Install Docker CLI (not cached in image, needed for buildx)
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
- name: Install Docker
|
||||||
run: |
|
run: |
|
||||||
apt-get update && apt-get install -y podman buildah
|
apt-get update -qq
|
||||||
|
apt-get install -y --no-install-recommends docker.io
|
||||||
|
|
||||||
- name: Podman info
|
# -------------------------------------------------------------------------
|
||||||
run: podman info
|
# Set up Docker Buildx for layer caching
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build with Buildah
|
# -------------------------------------------------------------------------
|
||||||
run: |
|
# Authenticate with Forgejo container registry
|
||||||
# 'bud' stands for Build-Using-Dockerfile
|
# -------------------------------------------------------------------------
|
||||||
buildah bud \
|
- name: Login to Registry
|
||||||
--storage-driver vfs \
|
uses: docker/login-action@v3
|
||||||
--isolation chroot \
|
with:
|
||||||
--net host \
|
registry: git.pmd5.org
|
||||||
-t "$CONTAINER_IMAGE" .
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
# Tagging is just as simple
|
|
||||||
buildah tag "$CONTAINER_IMAGE" "${{ secrets.REGISTRY_IMAGE }}:latest"
|
|
||||||
|
|
||||||
- name: Log in to registry
|
# -------------------------------------------------------------------------
|
||||||
run: |
|
# Build and push image with GitHub Actions cache
|
||||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | podman login \
|
# -------------------------------------------------------------------------
|
||||||
-u "${{ secrets.REGISTRY_USER }}" \
|
- name: Build and Push
|
||||||
--password-stdin \
|
uses: docker/build-push-action@v6
|
||||||
${{ secrets.REGISTRY_URL }}
|
with:
|
||||||
|
context: .
|
||||||
# - name: Push with Buildah
|
push: true
|
||||||
# run: |
|
tags: git.pmd5.org/${{ github.repository }}:latest
|
||||||
# # Buildah needs a 'docker://' prefix for remote registries
|
cache-from: type=gha
|
||||||
# # It will use the credentials from your previous 'podman login'
|
cache-to: type=gha,mode=max
|
||||||
# # OR you can login directly with buildah:
|
|
||||||
# buildah push \
|
|
||||||
# --storage-driver vfs \
|
|
||||||
# --creds "${{ secrets.REGISTRY_USER }}:${{ secrets.REGISTRY_PASSWORD }}" \
|
|
||||||
# "$CONTAINER_IMAGE" \
|
|
||||||
# "docker://${{ secrets.REGISTRY_IMAGE }}:latest"
|
|
||||||
|
|
||||||
# - name: Build Docker image
|
|
||||||
# run: |
|
|
||||||
# podman build -t "$CONTAINER_IMAGE" .
|
|
||||||
# podman tag "$CONTAINER_IMAGE" "${{ secrets.REGISTRY_IMAGE }}:latest"
|
|
||||||
#
|
|
||||||
# - name: Push Docker image
|
|
||||||
# run: |
|
|
||||||
# docker push "$CONTAINER_IMAGE"
|
|
||||||
# docker push "${{ secrets.REGISTRY_IMAGE }}:latest"
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue