Skip to content

Commit

Permalink
Add totally self-written docker image deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Rdeisenroth committed Jan 8, 2023
1 parent aa11c96 commit 4976d5a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/docker-img.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# shamelessly stolen from: https://github.com/CloudGoBrrr/server/blob/main/.github/workflows/main.yml
name: Build and publish container

on:
release:
types: [published]

jobs:
ghr_push:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Log-in to ghcr.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and push container image
run: |
IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# when the branch is master, replace master with latest
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
# Build and Publish container image
docker buildx build --push \
--tag $IMAGE_ID:$VERSION \
--build-arg CHECKOUT=${{ github.ref }} \
--build-arg VERSION=$VERSION \
--platform linux/amd64 .

0 comments on commit 4976d5a

Please sign in to comment.