Skip to content

Commit

Permalink
feat(ci): add comment with image ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampouille committed Oct 18, 2024
1 parent e843e48 commit 120a596
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,32 @@ jobs:
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
if: ${{ github.event.label.name == 'build' }}
if: ${{ contains( github.event.pull_request.labels.*.name, 'build') }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and push to ghcr
if: ${{ github.event.label.name == 'build' }}
if: ${{ contains( github.event.pull_request.labels.*.name, 'build') }}
run: |
TAG="pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)"
echo "TAG=${TAG}" >> $GITHUB_ENV
docker build -t ghcr.io/camptocamp/pg253:${TAG} \
--pull --no-cache \
--label GIT_COMMIT=$(git rev-parse HEAD) .
docker push ghcr.io/camptocamp/pg253:${TAG}
- uses: actions/github-script@v7
if: ${{ contains( github.event.pull_request.labels.*.name, 'build') }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "A docker image was successfully build for your Pull Request: `ghcr.io/camptocamp/pg253:${TAG}`"
})
- name: Build only
if: ${{ github.event.label.name != 'build' }}
if: ${{ not contains( github.event.pull_request.labels.*.name, 'build') }}
run: |
docker build --pull --no-cache .

0 comments on commit 120a596

Please sign in to comment.