Skip to content

map github cli config dir. #97

map github cli config dir.

map github cli config dir. #97

Workflow file for this run

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Create and publish a Docker image
# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
workflow_dispatch:
push:
branches:
- 'main'
- 'releases/**'
tags:
- 'v*'
pull_request:
branches:
- 'main'
env:
# Sets the Docker image tag to use for the image built in this workflow.
features_dir: src/features
base_dir: src/devcontainers
context: .devcontainer
workspace_folder: .
readme: README.md
registry: ghcr.io
dockerfile: Dockerfile
server: https://github.com
org: NHSDigital
repository: nhs-notify-devcontainers
vendor: NHS England
node_version: 24
temp_dockerfile: /tmp/Dockerfile.source
image_prefix: nhsdigital/nhs-notify-devcontainer-
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
deploy-nhs-notify-feature:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- '${{ env.features_dir }}/**'
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
name: "Publish Features"
uses: devcontainers/action@v1
with:
publish-features: "true"
base-path-to-features: "./${{ env.features_dir }}"
generate-docs: "false"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-push-image:
runs-on: ubuntu-latest
needs: [deploy-nhs-notify-feature]
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- container_name: base
title: NHS Notifiy Devcontainer Base Image
description: Base development container for NHS Notify projects
- container_name: default
title: NHS Notifiy Devcontainer Default Image
description: Default development container for NHS Notify projects
- container_name: loaded
title: NHS Notifiy Devcontainer Loaded Image
description: Loaded development container for NHS Notify projects
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v5
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- '${{env.base_dir}}/${{ matrix.container_name }}/**'
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
uses: actions/setup-node@v6
with:
node-version: ${{ env.node_version }}
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
name: Build
working-directory: ${{env.base_dir}}/${{ matrix.container_name }}
run: |
make build IMAGE_NAME=${{ env.registry }}/${{ env.image_prefix }}${{ matrix.container_name }} WORKSPACE_FOLDER=${{ env.workspace_folder }}
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.registry }}/${{ env.image_prefix }}${{ matrix.container_name }}
flavor: |
latest=auto
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
labels: |
org.opencontainers.image.title= ${{ matrix.title }}
org.opencontainers.image.description=${{ matrix.description }}
org.opencontainers.image.vendor=${{ env.vendor }}
org.opencontainers.image.url=${{ env.server }}/${{ env.org }}/${{ env.repository }}/blob/main/${{ env.base_dir }}/${{matrix.container_name}}/${{ env.readme }}
org.opencontainers.image.source=${{ env.server }}/${{ env.org }}/${{ env.repository }}/tree/main/${{ env.base_dir }}/${{matrix.container_name}}/
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
name: create temp dockerfile source
run: echo 'FROM ${{ env.registry }}/${{ env.image_prefix }}${{ matrix.container_name }}' > ${{ env.temp_dockerfile }}
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: ${{ env.temp_dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-name: ${{ env.registry }}/${{ env.image_prefix }}${{ matrix.container_name }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: false