Skip to content

Commit 0fe5c09

Browse files
committed
Add composite action for devcontainer commands
1 parent 4afe77e commit 0fe5c09

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 'Devcontainer CI Action'
2+
description: 'Run commands in devcontainer'
3+
inputs:
4+
command:
5+
description: 'Command to run in the devcontainer'
6+
required: true
7+
type: string
8+
devcontainer-path:
9+
description: 'Path to devcontainer config'
10+
required: false
11+
default: '.devcontainer'
12+
13+
runs:
14+
using: 'composite'
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Login to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.repository_owner }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Get devcontainer image name
27+
run: |
28+
image="ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-devcontainer"
29+
echo "IMAGE_NAME=${image,,}" >> $GITHUB_ENV
30+
31+
- name: Run command in devcontainer
32+
uses: devcontainers/[email protected]
33+
with:
34+
imageName: ${{ env.IMAGE_NAME }}
35+
cacheFrom: ${{ env.IMAGE_NAME }}
36+
push: always
37+
devcontainerPath: ${{ inputs.devcontainer-path }}
38+
runCmd: ${{ inputs.command }}

.github/workflows/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ jobs:
1616
cmake --build build --config Debug --target all
1717
cmake --build build --config Debug --target test
1818
cmake --build build --config Debug --target coverage
19+

.github/workflows/devcontainer-command.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,6 @@ jobs:
1616
packages: write
1717

1818
steps:
19-
- uses: actions/checkout@v4
20-
21-
- name: Login to GitHub Container Registry
22-
uses: docker/login-action@v3
23-
with:
24-
registry: ghcr.io
25-
username: ${{ github.repository_owner }}
26-
password: ${{ secrets.GITHUB_TOKEN }}
27-
28-
- name: Get devcontainer image name
29-
run: |
30-
image="ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-devcontainer"
31-
echo "IMAGE_NAME=${image,,}" >> $GITHUB_ENV
32-
33-
- name: Run command in devcontainer
34-
uses: devcontainers/[email protected]
19+
- uses: ${{ github.repository_owner }}/${{ github.event.repository.name }}/.github/actions/devcontainer@main
3520
with:
36-
imageName: ${{ env.IMAGE_NAME }}
37-
cacheFrom: ${{ env.IMAGE_NAME }}
38-
push: always
39-
runCmd: ${{ inputs.run_cmd }}
21+
command: ${{ inputs.run_cmd }}

0 commit comments

Comments
 (0)