Skip to content

Build and Release HPC Resource Provisioner #63

Build and Release HPC Resource Provisioner

Build and Release HPC Resource Provisioner #63

Workflow file for this run

---
name: Build and Release HPC Resource Provisioner
on:
workflow_dispatch:
inputs:
environment:
description: Which environment to push the image to
type: choice
options: [aws-sandbox-hpc]
required: true
default: aws-sandbox-hpc
jobs:
tag-and-release:
runs-on: ubuntu-latest
permissions:
contents: write
environment: ${{ inputs.environment }}
steps:
- name: clone repo
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Install resource provisioner
run: |-
python3 -m venv venv
source venv/bin/activate
pip install ./hpc_provisioner
- name: Determine version
run: |
echo REL_TAG=$(ls -d venv/lib/python3*/site-packages/hpc_provisioner*dist-info | awk -F- '{print $3}' | sed 's/.dist//') >> $GITHUB_ENV
- name: Create and upload tag ${{ env.REL_TAG }}
if: ${{ ! contains(env.REL_TAG, 'dev') }}
run: |
git config user.name github-actions
git config user.email [email protected]
git tag -a $REL_TAG -m "${REL_TAG}"
git push origin $REL_TAG
working-directory: ${{runner.workspace}}/hpc-resource-provisioner
- name: Authenticate with AWS ECR
uses: docker/[email protected]
with:
registry: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build and push container
run: |
SOURCE_CHECKSUM=$(find hpc_provisioner -type f -exec sha256sum {} \; | sha256sum | awk '{print $1}')
AWS_URI=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
AWS_PATH=hpc/resource-provisioner
docker build --build-arg SETUPTOOLS_SCM_PRETEND_VERSION=${REL_TAG} --label "org.opencontainers.image.checksum=${SOURCE_CHECKSUM}" --label "org.opencontainers.image.software_version=${REL_TAG}" -t ${AWS_PATH}:${REL_TAG} .
echo "Setting tags for aws ecr"
docker image tag ${AWS_PATH}:${REL_TAG} ${AWS_URI}/${AWS_PATH}:${REL_TAG}
docker image tag ${AWS_PATH}:${REL_TAG} ${AWS_URI}/${AWS_PATH}:latest
echo "Pushing to aws ecr"
docker push ${AWS_URI}/${AWS_PATH}:${REL_TAG}
docker push ${AWS_URI}/${AWS_PATH}:latest
working-directory: ${{runner.workspace}}/hpc-resource-provisioner
- name: Release
uses: softprops/action-gh-release@v2
if: github.ref == 'refs/heads/main'
with:
tag_name: ${{ env.REL_TAG }}
make_latest: true
body: |-
Latest container image will always be: `docker pull ghcr.io/openbraininstitute/hpc-resource-provisioner:latest`
This particular version is `docker pull ghcr.io/openbraininstitute/hpc-resource-provisioner:${{ env.REL_TAG }}`
- name: Version log
run: echo ::notice title=hpc-resource-provisioner version::${{ env.REL_TAG }}