https://telecominfraproject.atlassian.net/browse/WIFI-13246 #460
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: Build cluster systeminfo checker image | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
# TODO delete after tests | |
pull_request: | |
branches: | |
- main | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
docker: | |
runs-on: ubuntu-20.04 | |
env: | |
DOCKER_REGISTRY_URL: tip-tip-wlan-cloud-ucentral.jfrog.io | |
DOCKER_REGISTRY_USERNAME: ucentral | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build Docker image | |
working-directory: chart/docker | |
run: docker build -t wlan-cloud-clustersysteminfo:${{ github.sha }} . | |
- name: Tag Docker image | |
run: | | |
TAGS="${{ github.sha }}" | |
if [[ ${GITHUB_REF} == "refs/heads/"* ]] | |
then | |
CURRENT_TAG=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-') | |
TAGS="$TAGS $CURRENT_TAG" | |
else | |
if [[ ${GITHUB_REF} == "refs/tags/"* ]] | |
then | |
CURRENT_TAG=$(echo ${GITHUB_REF#refs/tags/} | tr '/' '-') | |
TAGS="$TAGS $CURRENT_TAG" | |
else # PR build | |
CURRENT_TAG=$(echo ${GITHUB_HEAD_REF#refs/heads/} | tr '/' '-') | |
TAGS="$TAGS $CURRENT_TAG" | |
fi | |
fi | |
echo "Result tags: $TAGS" | |
for tag in $TAGS; do | |
docker tag wlan-cloud-clustersysteminfo:${{ github.sha }} ${{ env.DOCKER_REGISTRY_URL }}/clustersysteminfo:$tag | |
done | |
- name: Log into Docker registry | |
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/pull/') || github.ref == 'refs/heads/main' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY_URL }} | |
username: ${{ env.DOCKER_REGISTRY_USERNAME }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
- name: Push Docker images | |
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/pull/') || github.ref == 'refs/heads/main' | |
run: | | |
docker images | grep ${{ env.DOCKER_REGISTRY_URL }}/clustersysteminfo | awk -F ' ' '{print $1":"$2}' | xargs -I {} docker push {} |