-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,88 @@ | ||
# TODO: Don't build if the PR is not based on master's HEAD | ||
# TODO: Only build the container if specific directories/files have changed, unless forced: https://coderwall.com/p/lz0uva/find-all-files-modified-between-commits-in-git | ||
name: test-command | ||
on: | ||
repository_dispatch: | ||
types: [test-command] | ||
|
||
jobs: | ||
|
||
build: | ||
env: | ||
AUTHORIZED: ${{ github.actor != github.event.client_payload.pull_request.base.repo.owner.login }} | ||
SOURCE_BRANCH: master | ||
DOCKER_REPO: embercsi/ci_images | ||
IMAGE_TAG: ${{ format('{0}-{1}', github.event.client_payload.pull_request.number, github.event.client_payload.pull_request.head.sha) }} | ||
DETAILS_URL: ${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }} | ||
JOB_NAME: internal/build-pr-images | ||
TAGS_MISSING: false | ||
|
||
# In the future we may want to return embercsi/ember-csi:{master,latest} | ||
outputs: | ||
image_base_name: ${{ format('{0}:{1}-', env.DOCKER_REPO, env.IMAGE_TAG) }} | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout the pull request branch from the repository | ||
- uses: actions/checkout@v2 | ||
if: env.AUTHORIZED == 'true' | ||
with: | ||
token: ${{ secrets.TOKEN }} | ||
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.client_payload.pull_request.head.ref }} | ||
|
||
- name: Notify in_progress | ||
run: | | ||
curl -X POST -H "Authorization: token ${{ secrets.TOKEN }}" -H "Content-Type: application/json" -d '{"context": "${{ env.JOB_NAME }}","state": "pending","target_url": "${{ env.DETAILS_URL }}"}' "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.client_payload.pull_request.head.sha }}" | ||
- name: Check if images exist | ||
if: env.AUTHORIZED == 'true' | ||
run: | | ||
for i in 7 8; do | ||
tag_info=`curl -fL --silent ${{ format('https://hub.docker.com/v2/repositories/{0}/tags/{1}', env.DOCKER_REPO, env.IMAGE_TAG) }}-$i` | ||
if [[ ! $tag_info == *'"name"'* ]]; then | ||
echo "::set-env name=TAGS_MISSING::true" | ||
break | ||
fi | ||
done | ||
- name: Build images | ||
if: env.AUTHORIZED == 'true' && env.TAGS_MISSING == 'true' | ||
run: | | ||
echo 'Start' | ||
echo "::add-mask::${{ secrets.DOCKER_PASSWORD }}" | ||
EMBER_VERSION=$IMAGE_TAG hooks/build | ||
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | ||
docker tag $DOCKER_REPO:master7 $DOCKER_REPO:${IMAGE_TAG}-7 | ||
docker tag $DOCKER_REPO:master8 $DOCKER_REPO:${IMAGE_TAG}-8 | ||
docker push $DOCKER_REPO:${IMAGE_TAG}-7 | ||
docker push $DOCKER_REPO:${IMAGE_TAG}-8 | ||
echo 'Done' | ||
- name: Get result status | ||
if: always() | ||
run: | | ||
status=`echo "${{ job.status }}" | tr '[:upper:]' '[:lower:]'` | ||
if [[ "$status" == "cancelled" ]]; then | ||
echo "::set-env name=JOB_RESULT::error" | ||
else | ||
echo "::set-env name=JOB_RESULT::$status" | ||
fi | ||
- name: Notify result status | ||
if: always() | ||
run: | | ||
curl -X POST -H "Authorization: token ${{ secrets.TOKEN }}" -H "Content-Type: application/json" -d '{"context": "${{ env.JOB_NAME }}","state": "${{ env.JOB_RESULT }}","target_url": "${{ env.DETAILS_URL }}"}' "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.client_payload.pull_request.head.sha }}" | ||
testing: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
strategy: | ||
matrix: | ||
centos: [7, 8] | ||
steps: | ||
- name: Testing | ||
run: | | ||
pwd | ||
echo Running with backend ${{ matrix.backend }} on a Centos ${{ matrix.centos }} VM | ||
echo Job is ${{ job }} |