Skip to content

Commit

Permalink
Get swagger docs from docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Volak committed Feb 5, 2024
1 parent 9a77d73 commit 7c492da
Showing 1 changed file with 58 additions and 39 deletions.
97 changes: 58 additions & 39 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
# Publish `vfrinx2.0.3` tags as releases.
tags:
- vfrinx2*
workflow_dispatch:

env:
# TODO: Change variable to your image's name.
Expand All @@ -17,9 +18,8 @@ env:
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push-v2:
build-image-v2:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2
Expand All @@ -28,44 +28,63 @@ jobs:
submodules: recursive

- name: Build image
run: docker build . --file docker/server/Dockerfile --tag $IMAGE_NAME --build-arg git_commit=$(git rev-parse HEAD)
run: docker build . --file docker/server/Dockerfile --tag $IMAGE_NAME:latest --build-arg git_commit=$(git rev-parse HEAD)

- name: Log into docker hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin

- name: Push image
run: |
IMAGE_ID=$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | 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/^vfrinx//')
# 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
# Add latest tag if we are on master and github.ref points to a tag
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
MASTER=$(git show-ref --hash origin/master)
echo "master: $MASTER"
HEAD=$(git rev-parse HEAD)
echo "head: $HEAD"
echo "github.ref ${{ github.ref }}"
if [[ $MASTER == $HEAD ]]; then
VERSION=latest
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
fi
fi
publish-latest-v2:
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: build-image-v2
steps:
- name: Inspect latest image
run: docker image inspect $IMAGE_NAME:latest

# - name: Push latest image
# run: docker push $IMAGE_NAME:latest

publish-release-v2:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: build-image-v2
steps:

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^vfrinx//')

- name: Push release image
run: docker tag $IMAGE_NAME:latest $IMAGE_NAME:${{ steps.get_version.outputs.VERSION }}

- name: Inspect release image
run: docker image inspect $IMAGE_NAME:${{ steps.get_version.outputs.VERSION }}

# - name: Push release image
# run: docker push $IMAGE_ID:${{ steps.get_version.outputs.VERSION }}

swagger-v2:
runs-on: ubuntu-latest
needs: build-image-v2
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Run conductor image
run: docker run -it --network host --entrypoint '' $IMAGE_NAME:latest sleep infinity

- name: Setup upterm session
uses: lhotari/action-upterm@v1

0 comments on commit 7c492da

Please sign in to comment.