mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-20 03:41:29 +08:00
91 lines
2.8 KiB
YAML
91 lines
2.8 KiB
YAML
##
|
|
## Build the Docker Debian image from source
|
|
##
|
|
|
|
name: Build Linux Source Image
|
|
|
|
# Only run when:
|
|
# - workflow is manually triggered
|
|
# - manually triggered via the ci.yml workflow
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
inputs:
|
|
docker_platforms:
|
|
required: true
|
|
description: "Arch to buid images"
|
|
type: string
|
|
default: linux/amd64
|
|
linux_version:
|
|
required: true
|
|
description: "Linux image to build"
|
|
type: string
|
|
default: debian
|
|
build_type:
|
|
required: true
|
|
description: Build type (source/binary)
|
|
type: string
|
|
default: source
|
|
secrets:
|
|
DOCKERHUB_USERNAME:
|
|
required: true
|
|
DOCKERHUB_PASSWORD:
|
|
required: true
|
|
|
|
jobs:
|
|
image:
|
|
name: Build Image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout the latest code
|
|
id: git_checkout
|
|
uses: actions/checkout@v3
|
|
- name: Set Vars
|
|
id: set_vars
|
|
run: |
|
|
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
|
echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
- name: Set up QEMU
|
|
id: docker_qemu
|
|
uses: docker/setup-qemu-action@v2
|
|
- name: Set up Docker Buildx
|
|
id: docker_buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Extract branch name
|
|
id: extract_branch
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
|
|
- name: Extract branch name (PR)
|
|
id: extract_branch_pr
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV
|
|
- name: Docker Metadata
|
|
id: docker_metadata
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: |
|
|
blockstack/${{ github.event.repository.name }}
|
|
tags: |
|
|
type=raw,value=${{ env.BRANCH_NAME }}
|
|
type=ref,event=pr
|
|
- name: Login to DockerHub
|
|
id: docker_login
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
- name: Build and Push
|
|
id: docker_build
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
file: ./.github/actions/dockerfiles/Dockerfile.${{ inputs.linux_version }}-${{ inputs.build_type }}
|
|
platforms: ${{ inputs.docker_platforms }}
|
|
tags: ${{ steps.docker_metadata.outputs.tags }}
|
|
labels: ${{ steps.docker_metadata.outputs.labels }}
|
|
build-args: |
|
|
STACKS_NODE_VERSION=${{ env.GITHUB_SHA_SHORT }}
|
|
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
|
|
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
|
|
push: true
|