-
Notifications
You must be signed in to change notification settings - Fork 34
NETOBSERV-229 create pre-merge image on PR via action #173
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: push to quay.io | ||
| name: Build and push to quay.io | ||
| on: | ||
| push: | ||
| branches: [ main ] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Build and push PR image to quay.io | ||
| on: | ||
| pull_request_target: | ||
| types: [labeled] | ||
|
|
||
| env: | ||
| REGISTRY_USER: netobserv+github_ci | ||
| REGISTRY: quay.io/netobserv | ||
| IMAGE: flowlogs-pipeline | ||
|
|
||
| jobs: | ||
| push-pr-image: | ||
| if: ${{ github.event.label.name == 'ok-to-test' }} | ||
| name: push PR image | ||
| runs-on: ubuntu-20.04 | ||
| strategy: | ||
| matrix: | ||
| go: ['1.17'] | ||
| steps: | ||
| - name: install make | ||
| run: sudo apt-get install make | ||
| - name: set up go 1.x | ||
| uses: actions/setup-go@v2 | ||
| with: | ||
| go-version: ${{ matrix.go }} | ||
| - name: checkout | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| ref: "refs/pull/${{ github.event.number }}/merge" | ||
| - name: build images | ||
| run: DOCKER_TAG=temp make build-ci-images | ||
| - name: podman login to quay.io | ||
| uses: redhat-actions/podman-login@v1 | ||
| with: | ||
| username: ${{ env.REGISTRY_USER }} | ||
| password: ${{ secrets.QUAY_SECRET }} | ||
| registry: quay.io | ||
| - name: get short sha | ||
| id: shortsha | ||
| run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" | ||
| - name: push to quay.io | ||
| id: push-to-quay | ||
| uses: redhat-actions/push-to-registry@v2 | ||
| with: | ||
| image: ${{ env.IMAGE }} | ||
| tags: ${{ steps.shortsha.outputs.short_sha }} | ||
| registry: ${{ env.REGISTRY }} | ||
| - uses: actions/github-script@v5 | ||
| 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: 'New image: ${{ steps.push-to-quay.outputs.registry-paths }}. It will expire after two weeks.' | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: Remove ok-to-test | ||
| on: | ||
| pull_request_target: | ||
| types: [synchronize,reopened] | ||
|
|
||
| jobs: | ||
| rm-ok-to-test: | ||
| if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') | ||
| runs-on: ubuntu-20.04 | ||
| name: Remove ok-to-test | ||
| steps: | ||
| - uses: actions-ecosystem/action-remove-labels@v1 | ||
| with: | ||
| labels: ok-to-test | ||
| fail_on_error: true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused. If this workflow is triggered by a PR, then what is the issue in context where the comment is created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in github API, a PR is apparently some special kind of issue. But the comment is actually created on the PR