Skip to content

Commit 9288a03

Browse files
committed
ci: fix issues with secrets and refactor further
1 parent b8cab65 commit 9288a03

File tree

4 files changed

+57
-28
lines changed

4 files changed

+57
-28
lines changed

.github/copilot-instructions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@ The folder structure of amp-devcontainer is described below, adhere to the exist
2424
- `/.devcontainer/[flavor]-test`: Contains a devcontainer.json file for testing the container flavor.
2525
- `/.github`: Contains the GitHub workflows for CI/CD, linter configuration, issue templates and re-usable actions.
2626
- `/test/[flavor]`: Contains [Bats](https://bats-core.readthedocs.io/en/stable/) integration- and Playwright verification tests for the containers.
27+
28+
## File Specific Instructions
29+
30+
When reviewing GitHub Action workflows, ensure that:
31+
32+
- Workflows that have a workflow_call trigger have the file name prefixed with `wc-`.
33+
- For all re-usable workflows, only the top-level workflow has defaults and descriptions for inputs to avoid duplication. Top-level workflows are not called themselves by other workflows with workflow_call.

.github/workflows/continuous-integration.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ concurrency:
1313
permissions: {}
1414

1515
jobs:
16-
build-push-test:
17-
uses: ./.github/workflows/wc-build-push-test-flavor.yml
16+
build-push-test-flavors:
17+
name: Build, Push and Test (🍨 ${{ matrix.flavor }})
18+
strategy:
19+
matrix:
20+
flavor: [cpp, rust]
21+
uses: ./.github/workflows/wc-build-push-test.yml
1822
secrets:
1923
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
2024
TEST_GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }}
@@ -28,3 +32,40 @@ jobs:
2832
id-token: write
2933
packages: write
3034
pull-requests: write
35+
with:
36+
devcontainer-metadata-file: .devcontainer/${{ matrix.flavor }}/devcontainer-metadata.json
37+
dockerfile: .devcontainer/${{ matrix.flavor }}/Dockerfile
38+
image-name: ${{ github.repository }}-${{ matrix.flavor }}
39+
integration-test-file: test/${{ matrix.flavor }}/integration-tests.bats
40+
41+
dependency-review:
42+
needs: build-push-test-flavors
43+
uses: ./.github/workflows/wc-dependency-review.yml
44+
permissions:
45+
contents: read
46+
pull-requests: write
47+
48+
publish-test-results:
49+
runs-on: ubuntu-latest
50+
permissions:
51+
checks: write
52+
pull-requests: write
53+
needs: build-push-test-flavors
54+
if: ${{ !cancelled() }}
55+
steps:
56+
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
57+
with:
58+
disable-sudo: true
59+
egress-policy: audit
60+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
61+
with:
62+
merge-multiple: true
63+
pattern: test-results-*
64+
- uses: EnricoMi/publish-unit-test-result-action@3a74b2957438d0b6e2e61d67b05318aa25c9e6c6 # v2.20.0
65+
with:
66+
files: test-report-*.xml
67+
68+
generate-documents:
69+
uses: ./.github/workflows/wc-document-generation.yml
70+
permissions:
71+
contents: read

.github/workflows/wc-build-push-test.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ jobs:
7272
packages: write
7373
pull-requests: write
7474
secrets:
75-
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME || github.actor }}
76-
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD || github.token }}
75+
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
76+
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
7777
with:
7878
dockerfile: ${{ inputs.dockerfile }}
7979
registry: ${{ inputs.registry }}
@@ -83,6 +83,7 @@ jobs:
8383
build-test-runner-labels: ${{ inputs.build-test-runner-labels }}
8484

8585
integration-test:
86+
if: ${{ inputs.integration-test-file }}
8687
strategy:
8788
matrix:
8889
runner: ${{ (startsWith(inputs.build-test-runner-labels, '[') && endsWith(inputs.build-test-runner-labels, ']')) && fromJson(inputs.build-test-runner-labels) || inputs.build-test-runner-labels }}
@@ -92,23 +93,3 @@ jobs:
9293
image-name: ${{ inputs.image-name }}
9394
test-file: ${{ inputs.integration-test-file }}
9495
runner-labels: ${{ matrix.runner }}
95-
96-
publish-test-results:
97-
runs-on: ubuntu-latest
98-
permissions:
99-
checks: write
100-
pull-requests: write
101-
needs: [integration-test]
102-
if: ${{ !cancelled() }}
103-
steps:
104-
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
105-
with:
106-
disable-sudo: true
107-
egress-policy: audit
108-
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
109-
with:
110-
merge-multiple: true
111-
pattern: test-results-*
112-
- uses: EnricoMi/publish-unit-test-result-action@3a74b2957438d0b6e2e61d67b05318aa25c9e6c6 # v2.20.0
113-
with:
114-
files: test-report-*.xml

.github/workflows/wc-build-push.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ jobs:
7171
- uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
7272
with:
7373
registry: ${{ inputs.registry }}
74-
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
75-
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
74+
username: ${{ secrets.DOCKER_REGISTRY_USERNAME || github.actor }}
75+
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD || github.token }}
7676
- uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
7777
env:
7878
DOCKER_METADATA_SET_OUTPUT_ENV: false
@@ -161,8 +161,8 @@ jobs:
161161
- uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
162162
with:
163163
registry: ${{ inputs.registry }}
164-
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
165-
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
164+
username: ${{ secrets.DOCKER_REGISTRY_USERNAME || github.actor }}
165+
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD || github.token }}
166166
- uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
167167
id: metadata
168168
env:

0 commit comments

Comments
 (0)