mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
82 lines
2.6 KiB
YAML
82 lines
2.6 KiB
YAML
name: Push image (REUSABLE)
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
IMAGE:
|
|
required: true
|
|
type: string
|
|
TAGS:
|
|
required: true
|
|
type: string
|
|
CACHE_FROM:
|
|
required: true
|
|
type: string
|
|
DOCKERFILE:
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
DOCKER_USERNAME:
|
|
required: true
|
|
DOCKER_TOKEN:
|
|
required: true
|
|
ARM_SSH_KEY:
|
|
required: true
|
|
ARM_SSH_CONFIG:
|
|
required: true
|
|
ARM_SSH_IP:
|
|
required: true
|
|
|
|
jobs:
|
|
push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# Prepare
|
|
- name: Check out repository code
|
|
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
- name: Login to ghcr
|
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Setup SSH for ARM node
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "$SSH_KEY" > ~/.ssh/id_rsa_arm
|
|
chmod 600 ~/.ssh/id_rsa_arm
|
|
echo "$SSH_CONFIG" | sed "s/SSH_IP/$SSH_IP/g" > ~/.ssh/config
|
|
env:
|
|
SSH_KEY: ${{ secrets.ARM_SSH_KEY }}
|
|
SSH_IP: ${{ secrets.ARM_SSH_IP }}
|
|
SSH_CONFIG: ${{ secrets.ARM_SSH_CONFIG }}
|
|
- name: Setup Buildx (ARM)
|
|
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
|
with:
|
|
endpoint: ssh://root@arm
|
|
platforms: linux/arm64,linux/arm/v7,linux/arm/v6
|
|
# Compute metadata
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
|
|
with:
|
|
images: bunkerity/${{ inputs.IMAGE }}
|
|
# Build and push
|
|
- name: Build and push
|
|
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
|
|
with:
|
|
context: .
|
|
file: ${{ inputs.DOCKERFILE }}
|
|
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
|
|
push: true
|
|
tags: ${{ inputs.TAGS }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: |
|
|
type=gha,scope=${{ inputs.CACHE_FROM }}-amd64
|
|
type=gha,scope=${{ inputs.CACHE_FROM }}-386
|
|
type=gha,scope=${{ inputs.CACHE_FROM }}-arm
|