mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-02-23 10:31:22 +01:00
Add Sanity test
Adding Tests to test the incoming code either through pull request or push to repository Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
f3ef3c1fb6
commit
c126414560
1 changed files with 53 additions and 0 deletions
53
.github/workflows/verify-push.yaml
vendored
Normal file
53
.github/workflows/verify-push.yaml
vendored
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# This workflow will perform a test whenever there
|
||||||
|
# is some change in code done to ensure that the changes
|
||||||
|
# are not buggy and we are getting the desired output.
|
||||||
|
name: Test Push
|
||||||
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: hello-world
|
||||||
|
IMAGE_REGISTRY: quay.io
|
||||||
|
IMAGE_TAG: latest
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Push image to Quay.io
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Fetch name of the Forked Repository with Branch
|
||||||
|
# if workflow is triggered from pull request
|
||||||
|
- name: Fetch PR head repo and branch name
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
run: |
|
||||||
|
HEAD_REPO_NAME=$(jq -r '.pull_request.head.repo.full_name' "$GITHUB_EVENT_PATH")
|
||||||
|
echo "PR head repo: $HEAD_REPO_NAME"
|
||||||
|
echo "repo=$HEAD_REPO_NAME" >> $GITHUB_ENV
|
||||||
|
echo "branch=$GITHUB_HEAD_REF" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Extract repository name with branch
|
||||||
|
- name: Fetch Repository name with branch
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "repo=$GITHUB_REPOSITORY" >> $GITHUB_ENV
|
||||||
|
echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Checkout push-to-registry action github repository
|
||||||
|
- name: Checkout Push to Registry action
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: ${{ env.repo }}
|
||||||
|
ref: ${{ env.branch }}
|
||||||
|
|
||||||
|
# Pull hello-world image to push in next step
|
||||||
|
- name: Pull Hello world image
|
||||||
|
run: docker pull ${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
# Push the image to image registry
|
||||||
|
- name: Push To Quay
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
image: ${{ env.IMAGE_NAME }}
|
||||||
|
tag: ${{ env.IMAGE_TAG }}
|
||||||
|
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
Loading…
Add table
Reference in a new issue