mirror of https://github.com/zcash/.github.git
first commit
This commit is contained in:
commit
56a8041c31
|
@ -0,0 +1,51 @@
|
|||
name: Build and Push Docker Image to Artifact Registry
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
image_name:
|
||||
description: ""
|
||||
required: true
|
||||
type: string
|
||||
image_tags:
|
||||
description: ""
|
||||
required: true
|
||||
type: string
|
||||
dockerfile:
|
||||
description: ""
|
||||
required: true
|
||||
type: string
|
||||
context:
|
||||
description: ""
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
project_id:
|
||||
required: true
|
||||
description: ""
|
||||
credentials_json:
|
||||
required: true
|
||||
description: ""
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Authenticate to Google Cloud
|
||||
uses: google-github-actions/auth@v2
|
||||
with:
|
||||
credentials_json: ${{ secrets.credentials_json }}
|
||||
|
||||
- name: Build and Push Docker Image to Artifact Registry
|
||||
uses: RafikFarhad/push-to-gcr-github-action@v5-beta
|
||||
with:
|
||||
registry: us-central1-docker.pkg.dev
|
||||
project_id: ${{ secrets.project_id }}
|
||||
image_name: base/${{ inputs.image_name }}
|
||||
image_tags: ${{ inputs.image_tag }}
|
||||
dockerfile: ${{ inputs.dockerfile }}
|
||||
context: ${{ inputs.context }}
|
|
@ -0,0 +1,71 @@
|
|||
name: Build and Push Docker Image to Docker Hub
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
image_name:
|
||||
description: "Name of the Docker image to build and push"
|
||||
required: true
|
||||
type: string
|
||||
image_tags:
|
||||
description: "Comma-separated list of tags for the Docker image"
|
||||
required: true
|
||||
type: string
|
||||
dockerfile:
|
||||
description: "Path to the Dockerfile"
|
||||
required: true
|
||||
type: string
|
||||
context:
|
||||
description: "Build context for the Docker image"
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
dockerhub_registry:
|
||||
required: true
|
||||
description: "Docker Hub registry URL (e.g., docker.io)"
|
||||
dockerhub_username:
|
||||
required: true
|
||||
description: "Docker Hub username"
|
||||
dockerhub_password:
|
||||
required: true
|
||||
description: "Docker Hub password"
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set Docker Image Tags
|
||||
id: set-tags
|
||||
run: |
|
||||
TAGS="${{ inputs.image_tags }}"
|
||||
REGISTRY="${{ secrets.dockerhub_registry }}/${{ inputs.image_name }}"
|
||||
IFS=',' read -ra ELEMENTS <<< "$TAGS"
|
||||
TAGS_FIXED=""
|
||||
for ELEMENT in "${ELEMENTS[@]}"; do
|
||||
TAGS_FIXED+="$REGISTRY:$ELEMENT,"
|
||||
done
|
||||
TAGS_FIXED=${TAGS_FIXED%,}
|
||||
echo "tags_fixed=$TAGS_FIXED" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.dockerhub_username }}
|
||||
password: ${{ secrets.dockerhub_password }}
|
||||
|
||||
- name: Build and Push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: ${{ inputs.dockerfile }}
|
||||
context: ${{ inputs.context }}
|
||||
push: true
|
||||
tags: ${{ env.tags_fixed }}
|
|
@ -0,0 +1,27 @@
|
|||
name: Standard Docker Container Versioning
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
tags:
|
||||
description: "tags of the docker image"
|
||||
value: ${{ jobs.set_env.outputs.tags }}
|
||||
|
||||
jobs:
|
||||
set_env:
|
||||
name: Create version tag
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
tags: ${{ steps.version_step.outputs.tags }}
|
||||
steps:
|
||||
- id: version_step
|
||||
run: |
|
||||
if [ "${{ github.ref_name }}" != "" ] && [ "${{ github.ref_name }}" != "main" ]; then
|
||||
echo "tags=${{ github.ref_name }},${{ github.sha }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
if [ "${{ github.ref_name }}" = "main" ]; then
|
||||
echo "tags=latest,${{ github.sha }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||
echo "tags=${{ github.event.pull_request.head.ref }},${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
|
||||
fi
|
Loading…
Reference in New Issue