HWPSupervisor grip/ungrip and ACU go_to_named #106
Workflow file for this run
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
name: Publish Docker Image to Registry | |
on: | |
release: | |
types: [ released ] | |
push: | |
branches: [ "main" ] | |
pull_request: | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: simonsobs/ocs-web | |
PULL_REQUEST: ${{ github.event_name == 'pull_request' }} # true on PR | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Grab tags during checkout | |
with: | |
fetch-depth: 0 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push the Docker image | |
run: | | |
# Build image | |
docker build . --file Dockerfile --tag ${REGISTRY}/${IMAGE_NAME}:latest | |
# Determine tag based on npm version within container | |
export DOCKER_TAG=$(git describe --tags --always) | |
echo "Docker Tag: ${DOCKER_TAG}" | |
# Tag image | |
docker tag ${REGISTRY}/${IMAGE_NAME}:latest ${REGISTRY}/${IMAGE_NAME}:${DOCKER_TAG} | |
# Push images only on push to main or release | |
if [[ "$GITHUB_REF_NAME" = "main" || "$GITHUB_EVENT_NAME" = "release" ]]; then | |
docker push ${REGISTRY}/${IMAGE_NAME}:${DOCKER_TAG} | |
else | |
echo "Skipping docker push; not on 'main' branch or a release." | |
fi | |
# Push 'latest' only on release | |
if [[ "$GITHUB_EVENT_NAME" = "release" ]]; then | |
docker push ${REGISTRY}/${IMAGE_NAME}:latest | |
else | |
echo "Not tagging 'latest'; this is not a release." | |
fi |