2020-10-06 19:13:00 -04:00
|
|
|
# vim: ts=2 sw=2:
|
|
|
|
|
|
|
|
name: Docker Build and Deploy
|
2020-03-28 18:18:29 -04:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
# Publish `master` as Docker `dev` image.
|
|
|
|
branches:
|
|
|
|
- master
|
2020-10-06 19:13:00 -04:00
|
|
|
# Publish `v*` tags as x.x.x images and as `latest`.
|
2020-03-28 18:18:29 -04:00
|
|
|
tags:
|
|
|
|
- v*
|
|
|
|
|
|
|
|
env:
|
|
|
|
IMAGE_NAME: qrm2
|
|
|
|
|
|
|
|
jobs:
|
2020-10-06 19:13:00 -04:00
|
|
|
docker:
|
|
|
|
name: Build and push docker images
|
|
|
|
runs-on: ubuntu-20.04
|
2020-03-28 18:18:29 -04:00
|
|
|
steps:
|
2020-10-06 19:13:00 -04:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
ref: ${{ github.ref }}
|
|
|
|
|
|
|
|
- name: Write ref to file
|
|
|
|
run: git rev-list -n 1 $GITHUB_REF > ./git_commit
|
2020-03-28 18:18:29 -04:00
|
|
|
|
|
|
|
- name: Build image
|
2020-10-06 19:13:00 -04:00
|
|
|
run: docker build . --file Dockerfile -t $IMAGE_NAME
|
2020-03-28 18:18:29 -04:00
|
|
|
|
|
|
|
- name: Log into Github Package Registry
|
|
|
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
|
|
|
|
|
2020-10-06 19:13:00 -04:00
|
|
|
- name: Tag image
|
|
|
|
id: tag_image
|
2020-03-28 18:18:29 -04:00
|
|
|
run: |
|
2020-10-06 19:13:00 -04:00
|
|
|
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
|
|
|
|
echo IMAGE_ID=$IMAGE_ID
|
|
|
|
echo ::set-output name=image_id::$IMAGE_ID
|
2020-03-28 18:18:29 -04:00
|
|
|
|
|
|
|
# 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//')
|
2020-10-06 19:13:00 -04:00
|
|
|
# if version is master, set version to dev
|
2020-03-28 18:18:29 -04:00
|
|
|
[[ "$VERSION" == "master" ]] && VERSION=dev
|
|
|
|
echo VERSION=$VERSION
|
2020-10-06 19:13:00 -04:00
|
|
|
echo ::set-output name=version::$VERSION
|
|
|
|
|
|
|
|
# tag dev or x.x.x
|
|
|
|
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
|
|
|
|
# tag latest if not a dev release
|
|
|
|
[[ "$VERSION" != "dev" ]] && docker tag $IMAGE_NAME $IMAGE_ID:latest
|
2020-03-28 18:18:29 -04:00
|
|
|
|
2020-10-06 19:13:00 -04:00
|
|
|
- name: Push images to registry
|
|
|
|
run: docker push ${{ steps.tag_image.outputs.image_id }}
|
2020-03-28 18:18:29 -04:00
|
|
|
|
2020-10-06 19:13:00 -04:00
|
|
|
# deploy:
|
|
|
|
# name: Deploy new images
|
|
|
|
# runs-on: ubuntu-20.04
|
|
|
|
# needs: docker
|
|
|
|
# steps:
|
|
|
|
# - name: Deploy official images
|
|
|
|
# id: deploy_images
|
|
|
|
# uses: satak/webrequest-action@v1.2.3
|
|
|
|
# with:
|
|
|
|
# url: ${{ secrets.DEPLOY_URL }}
|
|
|
|
# method: POST
|
|
|
|
# headers: '{"Authentication": "Token ${{ secrets.DEPLOY_TOKEN }}"}'
|
|
|
|
# payload: |
|
|
|
|
# '{
|
|
|
|
# "repository": "${{ github.repository }}",
|
|
|
|
# "version": "${{ jobs.docker.steps.tag_image.outputs.version }}"
|
|
|
|
# }'
|