Skip to content

Instantly share code, notes, and snippets.

@sjwaight
Created April 18, 2021 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjwaight/889a52b10934c74c1e197b2107aec7d0 to your computer and use it in GitHub Desktop.
Save sjwaight/889a52b10934c74c1e197b2107aec7d0 to your computer and use it in GitHub Desktop.
Sample GitHub Action that builds the MVC Music Store sample and pushes the container to Azure Container Registry
name: Build Windows Container Image
on:
push:
branches: [ post-containerisation ]
pull_request:
branches: [ post-containerisation ]
workflow_dispatch:
env:
dockerfilePath: 'MvcMusicStore-Completed\CIDockerfile'
USER: ${{ secrets.ACR_USER }}
TOKEN: ${{ secrets.ACR_SECRET }}
REPOSITORY: ${{ secrets.ACR_INSTANCE }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-deploy-to-azure:
# The type of runner that the job will run on
runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Build and push an image to container registry
run: |
docker login $env:REPOSITORY -u $env:USER -p $env:TOKEN
docker build --file=$env:dockerfilePath -t ${{ secrets.ACR_INSTANCE }}/${{ secrets.IMAGE_NAME }}:${{ github.run_id }} .
docker image push ${{ secrets.ACR_INSTANCE }}/${{ secrets.IMAGE_NAME }}:${{ github.run_id }}
docker logout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment