Skip to content

Configured compose.yml to build j-sp image instead of pulling from re… #49

Configured compose.yml to build j-sp image instead of pulling from re…

Configured compose.yml to build j-sp image instead of pulling from re… #49

name: Build and publish Docker image to Github Container Registry ghcr.io
on:
push:
branches-ignore:
- master
- version-*
- dependabot**
paths-ignore:
- README.md
- 'local-run/**'
jobs:
get-git-branch:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get branch name
id: branch
run: echo "branch_name=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Show git branch
run: echo ${{ steps.branch.outputs.branch_name }}
outputs:
branch: ${{ steps.branch.outputs.branch_name }}
get-commit-hash:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get SHA of the commit
id: sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Show short git hash
run: echo ${{ steps.sha.outputs.sha_short }}
outputs:
hash: ${{ steps.sha.outputs.sha_short }}
get-version:
runs-on: ubuntu-20.04
needs: [ get-git-branch, get-commit-hash ]
steps:
- uses: actions/checkout@v4
- name: Get package version
id: pack_ver
uses: notiz-dev/github-action-json-property@release
with:
path: package_info.json
prop_path: package_version
- name: Show version
run: echo ${{ steps.pack_ver.outputs.prop }}
outputs:
versionNumber: ${{ steps.pack_ver.outputs.prop }}
version: ${{ steps.pack_ver.outputs.prop }}-${{ needs.get-git-branch.outputs.branch }}-${{ github.run_id }}-${{ needs.get-commit-hash.outputs.hash }}
scan:
name: Vulnerabilities scan
uses: th2-net/.github/.github/workflows/python-scan.yml@main
docker-push:
runs-on: ubuntu-20.04
name: Build Docker image and push to ghcr.io
needs: [ get-version, scan ]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: '.'
push: true
tags: ghcr.io/${{ github.repository }}:${{ needs.get-version.outputs.version }}
labels: com.exactpro.th2.${{ github.repository }}=${{ needs.get-version.outputs.versionNumber }}
provenance: false
build-args: |
release_version=${{ needs.get-version.outputs.versionNumber }}