Skip to content

Commit b2f72b8

Browse files
committed
Prepare for v2
1 parent df22ccf commit b2f72b8

File tree

7 files changed

+10
-91
lines changed

7 files changed

+10
-91
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Continuous Integration
22
env:
3-
DOCKER_IMAGE: wyrihaximusgithubactions/composer.lock-diff
43
DOCKER_BUILDKIT: 1
54
on:
65
push:
@@ -49,16 +48,16 @@ jobs:
4948
- run: docker images
5049
env:
5150
REF: ${{ needs.generate-ref.outputs.ref }}
52-
- run: docker build --no-cache -t "${DOCKER_IMAGE}:${REF}" ./generate-comments/ -f generate-comments/Dockerfile-build --target=runtime
51+
- run: docker build --no-cache -t "$(echo "ghcr.io/${GITHUB_REPOSITORY}:${REF}" | tr '[:upper:]' '[:lower:]')" ./generate-comments/ -f generate-comments/Dockerfile-build --target=runtime
5352
env:
5453
REF: ${{ needs.generate-ref.outputs.ref }}
55-
- run: docker tag "${DOCKER_IMAGE}:${REF}" "${DOCKER_IMAGE}:sha-${GITHUB_SHA}"
54+
- run: docker tag "$(echo "ghcr.io/${GITHUB_REPOSITORY}:${REF}" | tr '[:upper:]' '[:lower:]')" "$(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')"
5655
env:
5756
REF: ${{ needs.generate-ref.outputs.ref }}
58-
- run: echo -e "${DOCKER_IMAGE}:${REF}" | xargs -I % sh -c 'docker run -v /tmp/trivy:/var/lib/trivy -v /var/run/docker.sock:/var/run/docker.sock -t aquasec/trivy:latest --cache-dir /var/lib/trivy image --exit-code 1 --no-progress --format table %'
57+
- run: echo -e "$(echo "ghcr.io/${GITHUB_REPOSITORY}:${REF}" | tr '[:upper:]' '[:lower:]')" | xargs -I % sh -c 'docker run -v /tmp/trivy:/var/lib/trivy -v /var/run/docker.sock:/var/run/docker.sock -t aquasec/trivy:latest --cache-dir /var/lib/trivy image --exit-code 1 --no-progress --format table %'
5958
env:
6059
REF: ${{ needs.generate-ref.outputs.ref }}
61-
- run: docker save "${DOCKER_IMAGE}:sha-${GITHUB_SHA}" | gzip -9 > ./docker-image/image.tar
60+
- run: docker save "$(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')" | gzip -9 > ./docker-image/image.tar
6261
if: github.actor == 'dependabot[bot]'
6362
- run: docker images
6463
- name: Upload Images
@@ -67,42 +66,22 @@ jobs:
6766
with:
6867
name: docker-image
6968
path: ./docker-image
70-
- name: Login to Docker Hub
71-
if: github.actor != 'dependabot[bot]'
72-
env:
73-
DOCKER_USER: ${{ secrets.HUB_USERNAME }}
74-
DOCKER_PASSWORD: ${{ secrets.HUB_PASSCODE }}
75-
run: |
76-
echo "${{ secrets.DOCKER_PASSWORD }}" | \
77-
docker login \
78-
--username "${{ secrets.DOCKER_USER }}" \
79-
--password-stdin
8069
- name: Login to GitHub Container Registry
8170
if: github.actor != 'dependabot[bot]'
8271
run: |
8372
echo "${{ secrets.GITHUB_TOKEN }}" | \
8473
docker login ghcr.io \
8574
--username "${GITHUB_ACTOR}" \
8675
--password-stdin
87-
- name: Push branch image to Docker Hub
88-
if: github.actor != 'dependabot[bot]'
89-
run: docker push "${DOCKER_IMAGE}:${REF}"
90-
env:
91-
REF: ${{ needs.generate-ref.outputs.ref }}
9276
- name: Push branch image to GitHub Container Registry
9377
if: github.actor != 'dependabot[bot]'
9478
run: |
95-
docker tag "${DOCKER_IMAGE}:${REF}" $(echo "ghcr.io/${GITHUB_REPOSITORY}:${REF}" | tr '[:upper:]' '[:lower:]')
9679
docker push $(echo "ghcr.io/${GITHUB_REPOSITORY}:${REF}" | tr '[:upper:]' '[:lower:]')
9780
env:
9881
REF: ${{ needs.generate-ref.outputs.ref }}
99-
- name: Push commit sha image to Docker Hub
100-
if: github.actor != 'dependabot[bot]'
101-
run: docker push "${DOCKER_IMAGE}:sha-${GITHUB_SHA}"
10282
- name: Push commit sha image to GitHub Container Registry
10383
if: github.actor != 'dependabot[bot]'
10484
run: |
105-
docker tag "${DOCKER_IMAGE}:sha-${GITHUB_SHA}" $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')
10685
docker push $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')
10786
comment-composer-lock-diff:
10887
name: Comment composer.lock diff
@@ -126,7 +105,7 @@ jobs:
126105
- run: docker load --input ./docker-image/image.tar
127106
if: github.actor == 'dependabot[bot]'
128107
- run: git branch
129-
- run: sed -i $(echo "s/main/sha-$GITHUB_SHA/g") generate-comments/Dockerfile
108+
- run: sed -i $(echo "s/main/sha-$GITHUB_SHA/g") action.yaml
130109
- name: Comment composer.lock diff
131110
if: github.actor != 'dependabot[bot]'
132111
uses: ./

.github/workflows/composer-diff.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
ref: ${{ github.event.pull_request.head.sha }}
2626
fetch-depth: 0
2727
- name: Comment composer.lock diff
28-
uses: WyriHaximus/github-action-composer.lock-diff@v1
28+
uses: WyriHaximus/github-action-composer.lock-diff@v2
2929
env:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/craft-release.yaml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Create Release
22
env:
3-
DOCKER_IMAGE: wyrihaximusgithubactions/composer.lock-diff
43
MILESTONE: ${{ github.event.milestone.title }}
54
on:
65
milestone:
@@ -79,15 +78,6 @@ jobs:
7978
version: ${{ fromJson(needs.generate-version-strategy.outputs.docker_versions) }}
8079
runs-on: ubuntu-latest
8180
steps:
82-
- name: Login to Docker Hub
83-
env:
84-
DOCKER_USER: ${{ secrets.HUB_USERNAME }}
85-
DOCKER_PASSWORD: ${{ secrets.HUB_PASSCODE }}
86-
run: |
87-
echo "${{ secrets.DOCKER_PASSWORD }}" | \
88-
docker login \
89-
--username "${{ secrets.DOCKER_USER }}" \
90-
--password-stdin
9181
- name: Login to GitHub Container Registry
9282
if: github.actor != 'dependabot[bot]'
9383
run: |
@@ -96,14 +86,11 @@ jobs:
9686
--username "${GITHUB_ACTOR}" \
9787
--password-stdin
9888
- name: Pull source image
99-
run: docker pull "${DOCKER_IMAGE}:sha-${GITHUB_SHA}"
89+
run: docker pull "$(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')"
10090
- name: Retag images for release
10191
run: |
102-
docker tag "${DOCKER_IMAGE}:sha-${GITHUB_SHA}" "${DOCKER_IMAGE}:${{ matrix.version }}"
103-
docker tag "${DOCKER_IMAGE}:sha-${GITHUB_SHA}" $(echo "ghcr.io/${GITHUB_REPOSITORY}:${{ matrix.version }}" | tr '[:upper:]' '[:lower:]')
92+
docker tag "$(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')" $(echo "ghcr.io/${GITHUB_REPOSITORY}:${{ matrix.version }}" | tr '[:upper:]' '[:lower:]')
10493
- run: docker images
105-
- name: Push release images to Docker Hub
106-
run: docker push "${DOCKER_IMAGE}:${{ matrix.version }}"
10794
- name: Push release images to GitHub Container Registry
10895
run: docker push $(echo "ghcr.io/${GITHUB_REPOSITORY}:${{ matrix.version }}" | tr '[:upper:]' '[:lower:]')
10996
create-release:
@@ -120,7 +107,7 @@ jobs:
120107
- uses: actions/checkout@v1
121108
- name: Create release/${{ matrix.version }} branch
122109
run: git checkout -b release/${{ matrix.version }} ${GITHUB_SHA}
123-
- run: sed -i 's/main/${{ matrix.version }}/g' Dockerfile
110+
- run: sed -i 's/main/${{ matrix.version }}/g' action.yaml
124111
- run: cat Dockerfile
125112
- run: git add Dockerfile
126113
- run: git status

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
ref: ${{ github.event.pull_request.head.sha }}
6565
fetch-depth: 0
6666
- name: Comment composer.lock diff
67-
uses: WyriHaximus/github-action-composer.lock-diff@v1
67+
uses: WyriHaximus/github-action-composer.lock-diff@v2
6868
env:
6969
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7070
```

action.yaml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ runs:
3333
owner: context.payload.repository.owner.login,
3434
repo: context.payload.repository.name,
3535
}));
36-
console.log({
37-
timeout: timeout,
38-
mcs: pr.data.merge_commit_sha,
39-
mergeable_state: pr.data.mergeable_state,
40-
});
4136
while (timeout < 60000 && pr.data.merge_commit_sha == null) {
4237
timeout *= 2;
4338
await new Promise(r => setTimeout(r, timeout));
@@ -46,22 +41,12 @@ runs:
4641
owner: context.payload.repository.owner.login,
4742
repo: context.payload.repository.name,
4843
}));
49-
console.log({
50-
timeout: timeout,
51-
mcs: pr.data.merge_commit_sha,
52-
mergeable_state: pr.data.mergeable_state,
53-
});
5444
}
5545
pr = (await github.rest.pulls.get({
5646
pull_number: context.payload.pull_request.number,
5747
owner: context.payload.repository.owner.login,
5848
repo: context.payload.repository.name,
5949
}));
60-
console.log({
61-
timeout: timeout,
62-
mcs: pr.data.merge_commit_sha,
63-
mergeable_state: pr.data.mergeable_state,
64-
});
6550
require('fs').appendFileSync(process.env.GITHUB_OUTPUT, `sha=${pr.data.merge_commit_sha}\n`);
6651
# const requests = Array.from({length: 8}, (v, i) => 500 * Math.pow(2, i)).map(timeout => resolveShaAfterTimeout(timeout));
6752
# console.log(requests);
@@ -87,26 +72,6 @@ runs:
8772
ref: ${{ github.event.pull_request.base.ref }}
8873
fetch-depth: 1
8974
path: .wyrihaximus-composer.lock-diff/checkout/base-ref
90-
# - name: Attempt to get branch point composer.lock
91-
# shell: bash
92-
# run: |
93-
# cd .wyrihaximus-composer.lock-diff/checkout/head-sha
94-
#
95-
# branchPoint=$(
96-
# git log --no-merges --graph --oneline --decorate origin/${{ github.event.pull_request.base.ref }}..$(git branch --show-current) | \
97-
# tac | \
98-
# grep -o '[a-f0-9]\{7,11\}' | \
99-
# head -n 1 | \
100-
# xargs -I '{}' git rev-parse "{}^"
101-
# )
102-
#
103-
# git show $branchPoint:composer.lock | cat > ".wyrihaximus-composer.lock-diff/branch-point-composer.lock"
104-
# - name: Cat branch point composer.lock
105-
# shell: bash
106-
# run: cat .wyrihaximus-composer.lock-diff/branch-point-composer.lock
107-
# - name: Cat base ref composer.lock
108-
# shell: bash
109-
# run: cat .wyrihaximus-composer.lock-diff/checkout/base-ref/composer.lock
11075
- name: Generate Comments
11176
uses: docker://ghcr.io/wyrihaximus/github-action-composer.lock-diff:main
11277
with:

generate-comments/Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

generate-comments/Dockerfile-run

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)