Skip to content

Commit 2554bef

Browse files
committed
ci: drop FranzDiebold/github-env-vars-action #9641
This drops the `FranzDiebold/github-env-vars-action` in favor of native GH-Actions replacement patterns available. ghcr.io (and other container registries for that matter) do not allow mix-case image names, so when a the repo is forked by a user with a mixed case username, or when reused in a repo with a mixed case repo name, the Docker image tagging step fails. When a lowercase username is needed it is now dynamically bash-eval'd directly in the called line. Notable replacements: - `${{ env.CI_REPOSITORY_OWNER_SLUG }}`: `$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')` - `${{ env.CI_REPOSITORY_NAME }}`: `${{ github.event.repository.name }}` Related: [#9639](http://team.linkorb.com/cards/9639).
1 parent 841489e commit 2554bef

File tree

1 file changed

+42
-47
lines changed

1 file changed

+42
-47
lines changed

.github/workflows/production.yml

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,64 +20,59 @@ jobs:
2020
- php8
2121

2222
steps:
23-
- name: GitHub Environment Variables Action
24-
uses: FranzDiebold/github-env-vars-action@v2
23+
- name: Shallow clone code
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
2527

26-
- name: Shallow clone code
27-
uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 0
28+
- name: Login to Container Registry ghcr.io
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.repository_owner }} # ghcr logins allow mixed case usernames
33+
password: ${{ secrets.GITHUB_TOKEN }}
3034

31-
- name: Login to Container Registry ghcr.io
32-
uses: docker/login-action@v3
33-
with:
34-
registry: ghcr.io
35-
username: ${{ env.CI_REPOSITORY_OWNER_SLUG }}
36-
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Build the container image
36+
run: docker build . --tag php-docker-base:trivytemp --file Dockerfile.${{ matrix.php }}
3737

38-
- name: Build the container image
39-
run: docker build . --tag php-docker-base:trivytemp --file Dockerfile.${{ matrix.php }}
38+
- name: Run Trivy vulnerability scanner
39+
uses: aquasecurity/trivy-action@master
40+
with:
41+
image-ref: php-docker-base:trivytemp
42+
format: 'table'
43+
exit-code: '1'
44+
ignore-unfixed: true
45+
vuln-type: 'os,library'
46+
severity: 'CRITICAL,HIGH'
4047

41-
- name: Run Trivy vulnerability scanner
42-
uses: aquasecurity/trivy-action@master
43-
with:
44-
image-ref: php-docker-base:trivytemp
45-
format: 'table'
46-
exit-code: '1'
47-
ignore-unfixed: true
48-
vuln-type: 'os,library'
49-
severity: 'CRITICAL,HIGH'
48+
- name: Retag new image with latest tag so we can push the scanned version
49+
run: docker image tag php-docker-base:trivytemp "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}"
5050

51-
- name: Retag new image with latest tag so we can push the scanned version
52-
run: docker image tag php-docker-base:trivytemp ghcr.io/${{ env.CI_REPOSITORY_OWNER_SLUG }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}
51+
- name: Push with commit ${{ matrix.php }} tag
52+
run: docker push "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}"
5353

54-
- name: Push with commit ${{ matrix.php }} tag
55-
run: docker push ghcr.io/${{ env.CI_REPOSITORY_OWNER_SLUG }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}
56-
57-
#review containers
58-
- name: Build the review container image
59-
run: docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}-review --file Dockerfile.${{ matrix.php }}-review
60-
- name: Push with commit *-review tag
61-
run: docker push ghcr.io/${{ env.CI_REPOSITORY_OWNER_SLUG }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}-review
54+
#review containers
55+
- name: Build the review container image
56+
run: docker build . --tag "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}-review" --file Dockerfile.${{ matrix.php }}-review
6257

58+
- name: Push with commit *-review tag
59+
run: docker push "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}-review"
6360

6461
cleanup:
6562
needs: [build]
6663
runs-on: ubuntu-latest
6764
steps:
68-
- name: GitHub Environment Variables Action
69-
uses: FranzDiebold/github-env-vars-action@v2
7065

71-
- name: Login to Container Registry ghcr.io
72-
uses: docker/login-action@v3
73-
with:
74-
registry: ghcr.io
75-
username: ${{ env.CI_REPOSITORY_OWNER_SLUG }}
76-
password: ${{ secrets.GITHUB_TOKEN }}
66+
- name: Login to Container Registry ghcr.io
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ghcr.io
70+
username: ${{ github.repository_owner }} #ghcr logins allow mixed case usernames
71+
password: ${{ secrets.GITHUB_TOKEN }}
7772

78-
- name: Delete old versions of the package, keeping a few of the newest
79-
uses: actions/delete-package-versions@v5
80-
with:
81-
package-name: ${{ env.CI_REPOSITORY_NAME }}
82-
package-type: container
83-
min-versions-to-keep: 8
73+
- name: Delete old versions of the package, keeping a few of the newest
74+
uses: actions/delete-package-versions@v5
75+
with:
76+
package-name: ${{ github.event.repository.name }}
77+
package-type: container
78+
min-versions-to-keep: 8

0 commit comments

Comments
 (0)