forked from OpenFAST/openfast
-
Notifications
You must be signed in to change notification settings - Fork 5
72 lines (65 loc) · 2.67 KB
/
build-docker-image-manual.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# This manually-triggered workflow builds OpenFAST docker images for the linux/amd64 and linux/aarch64 architectures for
# the specified git ref (this can be a branch, tag, or commit hash). The image is tagged with the given tag and pushed
# to the `nrel/openfast` repository. The build cache is stored in GitHub actions.
name: build-docker-image-manual
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag for Docker image (excluding the "v" prefix e.g. 3.5.3)'
required: true
ref:
description: 'Branch, tag, or commit SHA to build from'
required: true
default: main
jobs:
build-and-push:
runs-on: ubuntu-latest
timeout-minutes: 300
env:
DOCKERFILE_PATH: share/docker/Dockerfile
DOCKERFILE_PERMALINK: https://raw.githubusercontent.com/OpenFAST/openfast/main/share/docker/Dockerfile
DOCKERHUB_REPOSITORY: nrel/openfast
GH_REGISTRY: ghcr.io/OpenFAST/openfast
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Commenting out until we get the NREL DockerHub credentials
# - name: Log in to DockerHub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GH_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# The updated Dockerfile is only available in the repository at the tag v3.5.3 and above. To build versions of
# OpenFAST that are below this version, the updated Dockerfile from that tag of the repository has to be acquired
# before building. For versions >= v3.5.3, the Dockerfile is already there so this step does nothing.
- name: Get Dockerfile for versions < 3.5.3
run: |
if [ ! -f ${{ env.DOCKERFILE_PATH }} ]; \
then wget -O ${{ env.DOCKERFILE_PATH }} ${{ env.DOCKERFILE_PERMALINK }}; \
fi
- name: Build and push to registry
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
platforms: linux/amd64,linux/aarch64
tags: |
${{ env.GH_REGISTRY }}:${{ github.event.inputs.tag }}
# ${{ env.DOCKERHUB_REPOSITORY }}:${{ github.event.inputs.tag }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max