Skip to content

build-docker-image #759

build-docker-image

build-docker-image #759

Workflow file for this run

name: Build Docker-Image
on:
push:
branches:
- master
tags:
- '*'
repository_dispatch:
types: [build-docker-image]
jobs:
build-docker-image:
runs-on: ubuntu-latest
name: Build Docker Image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set Names
id: names
run: |
echo "name=ghcr.io/oggm/oggm" >> $GITHUB_OUTPUT
echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT
if [ "$GITHUB_REF" = refs/tags/* ]; then
echo "sha=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
else
echo "sha=$GITHUB_SHA" >> $GITHUB_OUTPUT
fi
- name: Stop Commands
run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
- name: Build image
uses: docker/build-push-action@v6
with:
context: deployment/docker
pull: true
load: true
provenance: false
build-args: |
GITHUB_SHA=${{ steps.names.outputs.sha }}
GITHUB_REPOSITORY=${{ github.repository }}
tags: |
${{ steps.names.outputs.name }}:test
- name: Test image
run: docker run --rm ${{ steps.names.outputs.name }}:test /root/test.sh
- name: Push image
uses: docker/build-push-action@v6
if: ${{ github.repository_owner == 'OGGM' }}
with:
context: deployment/docker
push: true
provenance: false
build-args: |
GITHUB_SHA=${{ steps.names.outputs.sha }}
GITHUB_REPOSITORY=${{ github.repository }}
tags: |
${{ steps.names.outputs.name }}:latest
${{ steps.names.outputs.name }}:${{ steps.names.outputs.date }}
${{ steps.names.outputs.name }}:${{ steps.names.outputs.sha }}