diff --git a/.github/workflows/docker-publish-webapp-dev.yml b/.github/workflows/docker-publish-webapp-dev.yml index a2e445466..38a555e25 100644 --- a/.github/workflows/docker-publish-webapp-dev.yml +++ b/.github/workflows/docker-publish-webapp-dev.yml @@ -16,6 +16,7 @@ on: env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io + PRIVATE_REGISTRY: khaneliman.azurecr.io # github.repository as / IMAGE_NAME: ${{ github.repository }}-webapp @@ -41,6 +42,14 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log into registry ${{ env.PRIVATE_REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.PRIVATE_REGISTRY }} + username: ${{ secrets.AZURECR_USER }} + password: ${{ secrets.AZURECR_PASS }} # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action @@ -48,7 +57,9 @@ jobs: id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + ${{ env.PRIVATE_REGISTRY }}/${{ env.IMAGE_NAME }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action diff --git a/.github/workflows/docker-publish-webapp.yml b/.github/workflows/docker-publish-webapp.yml index f85b6aeaa..89144dfea 100644 --- a/.github/workflows/docker-publish-webapp.yml +++ b/.github/workflows/docker-publish-webapp.yml @@ -12,10 +12,13 @@ on: tags: [ 'v*.*.*', 'latest' ] pull_request: branches: [ master ] + release: + types: [published] env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io + PRIVATE_REGISTRY: khaneliman.azurecr.io # github.repository as / IMAGE_NAME: ${{ github.repository }}-webapp @@ -42,13 +45,25 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + #Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.PRIVATE_REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.PRIVATE_REGISTRY }} + username: ${{ secrets.AZURECR_USER }} + password: ${{ secrets.AZURECR_PASS }} + # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + ${{ env.PRIVATE_REGISTRY }}/${{ env.IMAGE_NAME }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 95d4b10eb..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Docker -# Build and push an image to Azure Container Registry -# https://docs.microsoft.com/azure/devops/pipelines/languages/docker - -trigger: -- master -- releases/* - -resources: -- repo: self - -variables: - # Container registry service connection established during pipeline creation - dockerRegistryServiceConnection: '532cafaa-016a-49e0-8d01-a12876fadc96' - imageRepository: 'khanelimanwebapp' - containerRegistry: 'khaneliman.azurecr.io' - dockerfilePath: '$(Build.SourcesDirectory)/WebApp/Dockerfile' - tag: '$(Build.BuildId)' - - # Agent VM image name - vmImageName: 'ubuntu-latest' - -stages: -- stage: Build - displayName: Build and push stage - jobs: - - job: Build - displayName: Build - pool: - vmImage: $(vmImageName) - steps: - - task: Docker@2 - displayName: Build and push an image to container registry - inputs: - command: buildAndPush - repository: $(imageRepository) - dockerfile: $(dockerfilePath) - containerRegistry: $(dockerRegistryServiceConnection) - tags: | - $(tag)