Publish netconf-simulator #1
This file contains hidden or 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: Publish netconf-simulator | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Desired version of published docker image & helm charts, e.g. "XX.YY.ZZ" | |
| required: true | |
| image-tag-latest: | |
| description: Should be this docker labeled with tag latest? Enter `true` if the tag `latest` should be added for image. | |
| default: "true" | |
| required: true | |
| publish-access-key: | |
| description: The branch, tag or SHA to checkout. (if "default" the selected branch will be used) | |
| default: default | |
| required: true | |
| jobs: | |
| publish-docker-helm: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| IMAGE_NAME: "lighty-network-topology-device" | |
| PUBLISH_ACCESS_KEY: ${{ secrets.MM_PKG_WRITE }} | |
| name: "Publish netconf-simulator docker image. Checkout-ref: ${{ github.event.inputs.publish-access-key }}" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| - name: Build lighty-netconf-simulator | |
| shell: bash | |
| run: | | |
| echo "Building lighty-netconf-simulator..." | |
| mvn install -DskipTests | |
| - name: Run docker:build... | |
| shell: bash | |
| run: | | |
| echo "Image name set to:" ${{ env.IMAGE_NAME }} | |
| DOCKER_IMAGE_NAME=${{env.IMAGE_NAME}} | |
| DOCKER_IMAGE_NAME_TAG=$(echo $DOCKER_IMAGE_NAME:${{ inputs.version }}) | |
| DOCKER_IMAGE_NAME_GHCR=$(echo ghcr.io/pantheontech/${{ env.IMAGE_NAME }}) | |
| DOCKER_IMAGE_NAME_GHCR_TAG=$(echo $DOCKER_IMAGE_NAME_GHCR:${{ inputs.version }}) | |
| echo "docker build -t $DOCKER_IMAGE_NAME ." | |
| docker build -t $DOCKER_IMAGE_NAME . | |
| echo "Docker image tag:" $DOCKER_IMAGE_NAME_GHCR $DOCKER_IMAGE_NAME_GHCR_TAG | |
| docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME_TAG | |
| if [ "${{ inputs.image-tag-latest }}" = 'true' ]; then | |
| docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:latest | |
| fi | |
| docker images | grep $DOCKER_IMAGE_NAME | |
| - name: List docker images | |
| shell: bash | |
| run: | | |
| docker images | |
| - name: Docker log in (ghcr.io) | |
| shell: bash | |
| run: | | |
| echo ${{ inputs.publish-access-key}} | docker login --username ${{ github.actor }} --password-stdin ghcr.io | |
| - name: Publish docker image (ghcr.io) | |
| shell: bash | |
| run: | | |
| docker push $DOCKER_IMAGE_NAME_GHCR_TAG | |
| if [ "${{ inputs.image-tag-latest }}" = 'true' ]; then | |
| docker push $DOCKER_IMAGE_NAME_GHCR:latest | |
| fi | |
| - name: Check if docker image is pullable (ghcr.io) | |
| shell: bash | |
| run: | | |
| docker rmi $DOCKER_IMAGE_NAME_GHCR_TAG | |
| docker pull $DOCKER_IMAGE_NAME_GHCR_TAG | |
| - name: Install yq (yaml processor) | |
| shell: bash | |
| run: | | |
| sudo snap install yq | |
| - name: Set image.name, image.version in values.yaml of helm chart | |
| shell: bash | |
| run: | | |
| yq eval '.image.name="ghcr.io/pantheontech/$'"IMAGE_NAME"'" | .image.version="'${{ inputs.version }}'"' "${{ inputs.app-helm-values-path }}" -i | |
| - name: Print values.yaml | |
| shell: bash | |
| run: | | |
| cat -A ${{ inputs.app-helm-values-path }} |