2023-04-29 15:21:30 +02:00
|
|
|
name: Build Linux package (REUSABLE)
|
2023-03-01 17:46:40 +01:00
|
|
|
|
2023-03-02 11:56:14 +01:00
|
|
|
on:
|
2023-03-01 17:46:40 +01:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
2023-04-29 15:21:30 +02:00
|
|
|
RELEASE:
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-03-01 17:46:40 +01:00
|
|
|
LINUX:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
PACKAGE:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
secrets:
|
|
|
|
DOCKER_USERNAME:
|
|
|
|
required: true
|
|
|
|
DOCKER_TOKEN:
|
|
|
|
required: true
|
|
|
|
PRIVATE_REGISTRY:
|
|
|
|
required: true
|
|
|
|
PRIVATE_REGISTRY_TOKEN:
|
|
|
|
required: true
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
# Prepare
|
|
|
|
- name: Checkout source code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Buildx
|
|
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Login to private repository
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ${{ secrets.PRIVATE_REGISTRY }}
|
|
|
|
username: registry
|
|
|
|
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
|
2023-04-29 15:21:30 +02:00
|
|
|
# Build staging package image
|
2023-03-01 17:46:40 +01:00
|
|
|
- name: Build package image
|
2023-04-29 15:21:30 +02:00
|
|
|
if: inputs.RELEASE == 'staging'
|
2023-03-01 17:46:40 +01:00
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
load: true
|
|
|
|
file: src/linux/Dockerfile-${{ inputs.LINUX }}
|
|
|
|
platforms: linux/amd64
|
|
|
|
tags: local/bunkerweb-${{ inputs.LINUX }}:latest
|
|
|
|
cache-from: type=registry,ref=bunkerity/cache:${{ inputs.LINUX }}-staging
|
|
|
|
cache-to: type=registry,ref=bunkerity/cache:${{ inputs.LINUX }}-staging,mode=min
|
2023-04-29 15:21:30 +02:00
|
|
|
# Build non-staging package image
|
|
|
|
- name: Build package image
|
|
|
|
if: inputs.RELEASE != 'staging'
|
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
load: true
|
|
|
|
file: src/linux/Dockerfile-${{ inputs.LINUX }}
|
|
|
|
platforms: linux/amd64
|
|
|
|
tags: local/bunkerweb-${{ inputs.LINUX }}:latest
|
2023-03-01 17:46:40 +01:00
|
|
|
# Generate package
|
|
|
|
- name: Generate package
|
|
|
|
run: ./src/linux/package.sh ${{ inputs.LINUX }}
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: package-${{ inputs.LINUX }}
|
|
|
|
path: package-${{ inputs.LINUX }}/*.${{ inputs.PACKAGE }}
|
|
|
|
# Build test image
|
|
|
|
- name: Build test image
|
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: tests/linux/Dockerfile-${{ inputs.LINUX }}
|
|
|
|
platforms: linux/amd64
|
|
|
|
push: true
|
2023-04-29 15:21:30 +02:00
|
|
|
tags: ${{ secrets.PRIVATE_REGISTRY }}/infra/${{ inputs.LINUX }}-tests:${{ inputs.RELEASE }}
|