Skip to content

fix: fix dynamic devcontainer image name in build-devcontainer.yml #5

fix: fix dynamic devcontainer image name in build-devcontainer.yml

fix: fix dynamic devcontainer image name in build-devcontainer.yml #5

name: 'build devcontainer image'
on:
# rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- develop
permissions:
# write-all is too much, but we need to write to packages
# see https://github.com/orgs/community/discussions/57724 for more info
contents: read
packages: write
attestations: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-build image and run make ci-build in dev container
uses: devcontainers/ci@v0.3
with:
# push image only if the branch is main and the event is push
push: filter
refFilterForPush: refs/heads/main
eventFilterForPush: push
# name of the pushed image ("ghcr.io/wordpress-ionos/wordpress-ionos-devcontainer")
# we use variables here to make it more dynamic and reusable in forks
# devnote :
# workflow variable github.repository can be accessed as shell variable GITHUB_REPOSITORY.
# the to lowercase conversion can be done using bash inline substitution by appending @L to the variable name
imageName: "ghcr.io/${GITHUB_REPOSITORY@L}-devcontainer"
# enable caching (will build the image only if related files where changed)
# cacheFrom: ghcr.io/ionos-wordpress/ionos-wordpress-devcontainer
# make some tests to test the devcontainer image is working
runCmd: |
# test if pnpm is properly installed
command -v pnpm
# test if devcontainer environment is properly set
env | grep WP_ENV_HOME