Build Docker Image #177
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: Build Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "linux/amd64/Dockerfile" | |
| repository_dispatch: | |
| types: [upstream-changed] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build and push | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| env: | |
| GITHUB_REPO_LOWER: ${{ github.repository }} | |
| steps: | |
| - name: Set repo name to lowercase | |
| id: repo | |
| run: | | |
| echo "GITHUB_REPO_LOWER=$(echo ${{ env.GITHUB_REPO_LOWER }} | awk '{print tolower($0)}' | sed 's/\.docker$//I')" >> $GITHUB_ENV | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # - name: Set up QEMU | |
| # uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get current date | |
| id: date | |
| run: echo "DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| env: | |
| DATE: ${{ env.DATE }} | |
| with: | |
| context: . | |
| push: true | |
| tags: ghcr.io/${{ env.GITHUB_REPO_LOWER }}:debian-12 | |
| file: ./linux/amd64/Dockerfile | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: false | |
| labels: | | |
| org.opencontainers.image.created=${{ env.DATE }} | |
| org.opencontainers.image.source=https://github.com/workoho/AzAuto-Common-Runbook-FW.Docker/blob/${{ github.sha }}/linux/amd64/Dockerfile | |
| merge: | |
| name: Update :latest manifest | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| env: | |
| GITHUB_REPO_LOWER: ${{ github.repository }} | |
| steps: | |
| - name: Set repo name to lowercase | |
| id: repo | |
| run: | | |
| echo "GITHUB_REPO_LOWER=$(echo ${{ env.GITHUB_REPO_LOWER }} | awk '{print tolower($0)}' | sed 's/\.docker$//I')" >> $GITHUB_ENV | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get current date | |
| id: date | |
| run: echo "DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV | |
| - name: Create and push manifest | |
| env: | |
| GITHUB_REPO_LOWER: ${{ env.GITHUB_REPO_LOWER }} | |
| DATE: ${{ env.DATE }} | |
| run: | | |
| export DOCKER_CLI_EXPERIMENTAL=enabled | |
| docker manifest create ghcr.io/${{ env.GITHUB_REPO_LOWER }}:latest \ | |
| ghcr.io/${{ env.GITHUB_REPO_LOWER }}:debian-12 \ | |
| ghcr.io/${{ env.GITHUB_REPO_LOWER }}:debian-12-arm64 | |
| manifest=$(docker manifest inspect ghcr.io/${{ env.GITHUB_REPO_LOWER }}:latest) | |
| title="Azure Automation Common Runbook Framework" | |
| url="https://github.com/workoho/AzAuto-Common-Runbook-FW" | |
| documentation="https://github.com/workoho/AzAuto-Common-Runbook-FW/wiki" | |
| authors="Workoho GmbH" | |
| vendor="Workoho GmbH" | |
| licenses="MIT" | |
| description="This custom Microsoft PowerShell image is provided with pre-installed PowerShell modules that enable faster startup of development containers. It is compatible for x64 and ARM64 architectures, including Apple Silicon Macs." | |
| created="${{ env.DATE }}" | |
| source="https://github.com/workoho/AzAuto-Common-Runbook-FW.Docker/tree/${{ github.sha }}" | |
| annotations=".annotations = { | |
| \"org.opencontainers.image.title\": \"$title\", | |
| \"org.opencontainers.image.url\": \"$url\", | |
| \"org.opencontainers.image.documentation\": \"$documentation\", | |
| \"org.opencontainers.image.authors\": \"$authors\", | |
| \"org.opencontainers.image.vendor\": \"$vendor\", | |
| \"org.opencontainers.image.licenses\": \"$licenses\", | |
| \"org.opencontainers.image.description\": \"$description\", | |
| \"org.opencontainers.image.created\": \"$created\", | |
| \"org.opencontainers.image.source\": \"$source\" | |
| }" | |
| echo "$manifest" | jq "$annotations" | \ | |
| docker run -i ghcr.io/oras-project/oras:main manifest push \ | |
| --username ${{ github.repository_owner }} \ | |
| --password ${{ secrets.GITHUB_TOKEN }} \ | |
| ghcr.io/${{ env.GITHUB_REPO_LOWER }}:latest - | |
| trigger: | |
| name: Trigger GitHub Codespace prebuilds | |
| needs: | |
| - merge | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| repo: | |
| [ | |
| "Workoho/AzAuto-Common-Runbook-FW", | |
| "Workoho/AzAuto-Project.tmpl", | |
| "Workoho/Entra-Tiering-Security-Model", | |
| ] | |
| steps: | |
| - name: Trigger prebuild | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.REPO_PAT_FULL }} | |
| repository: ${{ matrix.repo }} | |
| event-type: prebuild |