Docker #256
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
on: | |
push: | |
# Publish `master` as Docker `latest` image. | |
branches: | |
- master | |
# Publish `vfrinx2.0.3` tags as releases. | |
tags: | |
- vfrinx2* | |
workflow_dispatch: | |
env: | |
# TODO: Change variable to your image's name. | |
IMAGE_NAME: frinx/conductor-server | |
jobs: | |
# Push image to GitHub Packages. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
build-image-v2: | |
runs-on: ubuntu-latest | |
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@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Build image | |
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: Inspect latest image | |
run: docker image inspect $IMAGE_NAME:latest | |
# - name: Push latest image | |
# run: docker push $IMAGE_NAME:latest | |
- name: Get the version | |
if: startsWith(github.ref, 'refs/tags/v') | |
id: get_version | |
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^vfrinx//') | |
- name: Push release image | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: docker tag $IMAGE_NAME:latest $IMAGE_NAME:${{ steps.get_version.outputs.VERSION }} | |
- name: Inspect release image | |
if: startsWith(github.ref, 'refs/tags/v') | |
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 }} | |
- name: Run conductor image | |
run: docker run -d --network "$(docker network ls --filter type=custom --format '{{ .Name }}')" --publish 8080:8080 $IMAGE_NAME:latest | |
- name: Setup upterm session | |
uses: lhotari/action-upterm@v1 | |
- name: Get conductor openapi spec | |
run: curl http://localhost:8080/v3/api-docs -o openapi.json | |
- name: Check out swagger_docs branch | |
uses: actions/checkout@v4 | |
with: | |
ref: swagger_docs | |
path: swagger_docs | |
fetch-depth: 2 | |
- name: Commit report | |
run: | | |
git_hash=$(git rev-parse --short "$GITHUB_SHA") | |
git_branch=${GITHUB_REF#refs/heads/} | |
cp openapi.json swagger_docs/latest.json | |
pushd swagger_docs || exit 1 | |
git config -l --show-scope | |
git config --global user.email "[email protected]" | |
git config --global user.name "FRINXrepo" | |
git add latest.json | |
git commit -am "Automated report" | |
git commit -am "Updated swagger for ${git_branch}/${git_hash}" | |
popd |