Skip to content

Build docker image

Build docker image #23

Workflow file for this run

permissions:
contents: read
packages: write
on:
release:
types: [created]
workflow_dispatch:
inputs:
environment:
description: 'Select the environment'
required: true
default: 'production'
type: choice
options:
- production
- staging
branch:
description: 'Select the branch'
required: true
default: 'main'
name: Build docker image
jobs:
build:
name: KernelCI Storage Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Retrieve github username
run: echo "${{ github.actor }}" > github_username.txt
- name: Set name of docker image on staging
if: ${{ github.event.inputs.environment == 'staging' }}
run: echo "ghcr.io/${{ github.repository_owner }}/kernelci-storage:staging" > image_name.txt
- name: Set name of docker image on production
if: ${{ github.event.inputs.environment == 'production' }}
run: echo "ghcr.io/${{ github.repository_owner }}/kernelci-storage:latest" > image_name.txt
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and push
run: |
docker buildx build --platform linux/amd64 -t $(cat image_name.txt) --push .