Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Workflow fixes

Russ Garrettc0ac04e8b6c9
diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml
index a2ed9d8..98f7619 100644
--- a/.github/workflows/build-and-deploy.yml
+++ b/.github/workflows/build-and-deploy.yml
@@ -5,6 +5,7 @@ on:
env:
IMAGE_NAME: web-backend
+ SHA8: ${GITHUB_SHA::8}
jobs:
build:
@@ -17,19 +18,18 @@ jobs:
- name: Build
run: docker build . --tag $IMAGE_NAME
- - name: Log into GitHub Container Registry
- run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
-
- name: Push image to GitHub Container Registry
+ if: github.ref == 'refs/heads/main'
run: |
+ echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
+
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
- VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
- [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
- # Use Docker `latest` tag convention
- [ "$VERSION" == "master" ] && VERSION=latest
+
echo IMAGE_ID=$IMAGE_ID
- echo VERSION=$VERSION
+ echo VERSION=$SHA8
- docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
- docker push $IMAGE_ID:$VERSION
+ docker tag $IMAGE_NAME $IMAGE_ID:$SHA8
+ docker push $IMAGE_ID:$SHA8
+ docker tag $IMAGE_NAME $IMAGE_ID:latest
+ docker push $IMAGE_ID:latest