@@ -6,7 +6,8 @@ name: Build Dev Container for Azure RTOS
66env :
77 CONTAINER_REPO : ghcr.io
88 CONTAINER_NAME : dev-container-azure-rtos
9- CONTAINER_SRC_FILE : .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC
9+ CONTAINER_SOURCE_FILE : .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC
10+ CONTAINER_VERSION_FILE : .devcontainer/AzureRTOS/Dockerfile.AzureRTOS
1011
1112on :
1213 push :
@@ -21,34 +22,38 @@ jobs:
2122 build :
2223 if : ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
2324 runs-on : ubuntu-latest
24- steps :
25+ permissions :
26+ contents : read
27+ packages : write
2528
29+ steps :
2630 - name : Checkout Repository
2731 uses : actions/checkout@v4
2832
2933 - name : Get container version
34+ shell : pwsh
3035 run : |
31- $dockerfileContent = Get-Content(".devcontainer/AzureRTOS/Dockerfile.AzureRTOS ")
36+ $dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }} ")
3237 $dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
3338 $containerVersion = $Matches[0].ToString()
3439 echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
35- shell : pwsh
3640
3741 - name : Set up Docker Buildx
38- uses : docker/setup-buildx-action@v2
42+ uses : docker/setup-buildx-action@v3
3943
4044 - name : Login to GitHub Container Registry
41- uses : docker/login-action@v2
45+ if : ${{ github.event_name != 'pull_request' }}
46+ uses : docker/login-action@v3
4247 with :
43- registry : ghcr.io
48+ registry : ${{ env.CONTAINER_REPO }}
4449 username : ${{ github.repository_owner }}
45- password : ${{ secrets.CONTAINER_BUILD_TOKEN }}
50+ password : ${{ secrets.GITHUB_TOKEN }}
4651
4752 - name : Build and Push Docker Image
4853 uses : docker/build-push-action@v5
4954 with :
50- file : ${{ env.CONTAINER_SRC_FILE }}
51- push : true # Will only build if this is not here
55+ file : ${{ env.CONTAINER_SOURCE_FILE }}
56+ push : ${{ github.event_name != 'pull_request' }}
5257 tags : |
5358 ${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
5459 ${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
0 commit comments