Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address docker images for PRs failing to build for external PRs #737

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/pull-request-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
path: |
dist
retention-days: 1

push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
Expand Down Expand Up @@ -85,21 +86,45 @@ jobs:

- name: Log in to Docker Hub
uses: docker/login-action@v3
if: github.event.pull_request.head.repo.full_name == github.repository
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
if: github.event.pull_request.head.repo.full_name == github.repository
with:
context: .
file: ./Dockerfile
push: true
tags: grafana/plugin-builds:${{ github.event.pull_request.head.sha }}pre

- name: Build Docker image for use with Docker save
uses: docker/build-push-action@v5
if: ${{github.event.pull_request.head.repo.full_name != github.repository}}
with:
context: .
file: ./Dockerfile
push: false
tags: grafana/plugin-builds:${{ github.event.pull_request.head.sha }}pre

- name: Save Docker image
shell: bash
run: docker save -o ${{ github.event.pull_request.head.sha }}pre.tar grafana/plugin-builds:${{ github.event.pull_request.head.sha }}pre

- name: Archive Docker image
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.pull_request.head.sha }}pre
path: ${{ github.event.pull_request.head.sha }}pre.tar
retention-days: 5

add_pr_comment:
name: Add PR comment
runs-on: ubuntu-latest
needs: push_to_registry
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Find previous comment (if any)
uses: peter-evans/find-comment@v3
Expand Down Expand Up @@ -130,4 +155,3 @@ jobs:

```
docker run --rm -p 3000:3000 grafana/plugin-builds:${{ github.event.pull_request.head.sha }}pre
```
Loading