Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

GH action

Russ Garrett8b42a444d60e
diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml
new file mode 100644
index 0000000..aff009b
--- /dev/null
+++ b/.github/workflows/build-and-deploy.yml
@@ -0,0 +1,35 @@
+name: Build and Publish
+
+on:
+ push:
+
+env:
+ IMAGE_NAME: web-backend
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ if: github.event_name == 'push'
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Build
+ run: docker build . --tag $IMAGE_NAME
+
+ - name: Log into GitHub Container Registry
+ run: echo "${{ GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
+
+ - name: Push image to GitHub Container Registry
+ run: |
+ IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
+ 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
+
+ docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
+ docker push $IMAGE_ID:$VERSION