Merge pull request #742 from tolkamps1/epicsystem-23-add-comment-peri… #35
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
name: Build | |
on: | |
push: | |
branches: | |
- develop | |
paths-ignore: | |
- '.github/**' | |
- 'openshift/**' | |
env: | |
OPENSHIFT_NAMESPACE: 6cdc9e-tools | |
IMAGE_NAME: eagle-api | |
TEST_PROMO_BRANCH: promotion/test | |
TEST_PROMO_PR_BRANCH: promotion/test-pr | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
outputs: | |
SHORT_SHA: ${{ steps.short-sha.outputs.SHA }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Login to OpenShift registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ secrets.OPENSHIFT_REPOSITORY }} | |
username: ${{ secrets.OPENSHIFT_REPOSITORY_USERNAME }} | |
password: ${{ secrets.OPENSHIFT_REPOSITORY_PASSWORD }} | |
- name: Get Short SHA | |
id: short-sha | |
run: echo "::set-output name=SHA::$(git rev-parse --short HEAD)" | |
- name: Setup and Build | |
id: build_image | |
uses: redhat-actions/s2i-build@v2 | |
with: | |
path_context: '.' | |
builder_image: ${{ secrets.OPENSHIFT_REPOSITORY }}/openshift/nodejs:10 | |
image: ${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }} | |
tags: ci-latest | |
- name: Push Docker image | |
run: docker push ${{ steps.build_image.outputs.image }}:ci-latest | |
promotion: | |
name: Create Promotion Pull Request | |
needs: build | |
runs-on: ubuntu-20.04 | |
steps: | |
# Update promotion/test-pr with new commit hash | |
- name: Checkout promotion/test | |
uses: actions/checkout@v2 | |
with: | |
ref: '${{ env.TEST_PROMO_BRANCH }}' | |
- name: Update state.json | |
run: | | |
git config --global user.name "${{ github.actor }}" | |
git config --global user.email "${{github.actor}}@users.noreply.github.com" | |
git checkout -B ${{ env.TEST_PROMO_PR_BRANCH }} | |
git reset --hard ${{ env.TEST_PROMO_BRANCH }} | |
echo $(jq '.commit="${{ needs.build.outputs.SHORT_SHA }}"' state.json) > state.json | |
git commit -am "Promote commit ${{ needs.build.outputs.SHORT_SHA }} to Test" | |
git push --force origin ${{ env.TEST_PROMO_PR_BRANCH }} | |
- name: Create Pull Request | |
uses: repo-sync/pull-request@v2 | |
with: | |
source_branch: ${{ env.TEST_PROMO_PR_BRANCH }} | |
destination_branch: ${{ env.TEST_PROMO_BRANCH }} | |
pr_title: 'Deploy to Test Environment' | |
pr_body: | | |
:crown: *An automated PR* | |
This PR triggers an deployment to Test once it's fully merged. | |
pr_label: 'auto-pr,test env,pipeline' | |
pr_draft: true | |
github_token: ${{ secrets.GITHUB_TOKEN }} |