Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/docker-image-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker Image CI

on:
release:
types: [published]

env:
IMAGE_NAME: learninglocker/xapi-service

jobs:
main:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'

- name: Installing Dependencies
run: yarn install --ignore-engines --frozen-lockfile

- name: Compiling Code
run: yarn build

- name: Determine version
id: version
run: |
# 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//')
echo "version=$version" >> $GITHUB_OUTPUT

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

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

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
build-args: |
GIT_COMMIT=${{ github.sha }}
VERSION=${{ steps.version.outputs.version }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}