Angular - Docker #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: Angular - Docker | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'src/Kendo/**/*' | |
| env: | |
| CONTAINER_REGISTRY: "docker.io" | |
| CONTAINER_REPOSITORY: "lancemccarthy/kendo-demo" | |
| jobs: | |
| dockerfile_to_dockerhub: | |
| name: "Dockerfile Build and Publish" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Generate tag version | |
| id: tag-creator | |
| run: | | |
| buildDay=`date +%Y.%m.%d` | |
| tags="$buildDay.$GITHUB_RUN_NUMBER" | |
| echo "VERSION_TAG=$tags" >> $GITHUB_OUTPUT | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{secrets.DOCKER_HUB_USERNAME}} | |
| password: ${{secrets.DOCKER_HUB_PAT}} | |
| - name: Get package metadata from Docker Hub | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{env.CONTAINER_REGISTRY}}/${{env.CONTAINER_REPOSITORY}} | |
| - name: Build and Publish arm64, amd64 Container Images | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: src/Kendo/angular_demo | |
| platforms: linux/arm64,linux/amd64 | |
| push: true | |
| secrets: | | |
| telerik-nuget-key=${{secrets.TELERIK_NUGET_KEY}} | |
| telerik-license-key=${{secrets.TELERIK_LICENSE_KEY}} | |
| tags: | | |
| ${{steps.meta.outputs.tags}} | |
| ${{env.CONTAINER_REGISTRY}}/${{env.CONTAINER_REPOSITORY}}:${{steps.tag-creator.outputs.VERSION_TAG}} | |
| # Required because actions/delete-package-versions@v5 does not work with Docker Hub | |
| - name: Delete old (untagged) images | |
| run: | | |
| IMAGE_TAGS=$(curl -s "https://hub.docker.com/v2/repositories/${{env.CONTAINER_REPOSITORY}}/tags/?page_size=100" | jq -r '.results|.[]|.name') | |
| for TAGG in $IMAGE_TAGS; do | |
| if [[ "$TAGG" == "null" ]]; then | |
| docker rmi "${{env.CONTAINER_REPOSITORY}}:$TAGG" | |
| curl -s -X DELETE "https://hub.docker.com/v2/repositories/${{env.CONTAINER_REPOSITORY}}/tags/$TAGG/" | |
| fi | |
| done | |
| # - name: Trigger Portainer to pull images and redeploy the stack | |
| # run: curl -X POST ${{secrets.PORTAINER_WEBHOOK_KENDO}} |