Skip to content

Add FreeRTOS NXP container (#2855) #1

Add FreeRTOS NXP container (#2855)

Add FreeRTOS NXP container (#2855) #1

# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
name: Push Docker image [FreeRTOS-NXP]
env:
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-freertos-nxp
CONTAINER_SOURCE_FILE: .devcontainer/FreeRTOS-NXP/Dockerfile.FreeRTOS-NXP.SRC
CONTAINER_VERSION_FILE: .devcontainer/FreeRTOS-NXP/Dockerfile.FreeRTOS-NXP
on:
push:
branches:
- main
paths:
- '**Dockerfile.FreeRTOS-NXP' # We only care if the version has changed!
workflow_dispatch:
jobs:
build:
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get container version
shell: pwsh
run: |
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REPO }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.CONTAINER_SOURCE_FILE }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest