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:
divyansh42 2020-11-27 16:18:22 +05:30 committed by Tim Etchells
parent f3ef3c1fb6
commit c126414560

53
.github/workflows/verify-push.yaml vendored Normal file
View 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 }}