deploy #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uploads the `openfast` python package to PyPI before building an OpenFAST docker image for the | |
# linux/amd64 and linux/aarch64 architectures on release. The image is tagged both with "latest" and the version | |
# extracted from the release candidate branch's name (e.g. "rc-3.5.3") before being pushed to the `nrel/openfast` | |
# repository. The build cache is stored in GitHub actions. | |
name: deploy | |
on: | |
workflow_dispatch: | |
release: | |
types: | |
- released | |
jobs: | |
publish-to-pypi: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
uses: snok/[email protected] | |
- name: Build a binary wheel and a source tarball | |
run: poetry build | |
- name: Publish package distributions to PyPI | |
uses: pypa/[email protected] | |
docker-build-and-push: | |
runs-on: ubuntu-latest | |
timeout-minutes: 300 | |
env: | |
DOCKERFILE_PATH: 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 | |
- 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 }} | |
- name: Extract tag from release candidate branch name | |
id: extract-tag | |
run: echo "openfast-tag=$(expr substr "${{ github.head_ref }}" 4 100)" >> $GITHUB_OUTPUT | |
- 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 }}:${{ steps.extract-tag.outputs.openfast-tag }},${{ env.DOCKERHUB_REPOSITORY }}:latest | |
# ${{ env.DOCKERHUB_REPOSITORY }}:${{ steps.extract-tag.outputs.openfast-tag }},${{ env.DOCKERHUB_REPOSITORY }}:latest | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |