Skip to content

Ci stable release #1065

Ci stable release

Ci stable release #1065

name: Build and release
on:
push:
branches:
- main
- stage-stable
- prod-beta
- prod-stable
pull_request:
jobs:
commit:
name: "💾 Commit message"
if: github.ref_name != 'main' && github.ref_name != 'prod-beta' && ! contains(github.ref_name, 'stable')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
path: code
- uses: actions/checkout@v3
with:
repository: "RHEnVision/changelog"
path: changelog
- run: pip3 install ./changelog
- run: python3 -m rhenvision_changelog commit-check
working-directory: code
build:
name: "📎 Lint, test and build"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.14.0]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Running tests
run: npm test
- name: Run build
run: yarn build
- uses: actions/upload-artifact@v3
with:
name: build
path: dist/*
Release-to-build:
name: "⛵ Release to build repository"
needs: [build]
if: github.ref_name == 'main' || github.ref_name == 'prod-beta' || contains(github.ref_name, 'stable')
runs-on: ubuntu-latest
env:
COMMIT_AUTHOR_USERNAME: GitHub actions
COMMIT_AUTHOR_EMAIL: [email protected]
steps:
- uses: actions/checkout@v3
- run: mkdir ${{ github.workspace }}/.travis
- name: Pull the Jenkins file
run: curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/Jenkinsfile > ${{ github.workspace }}/.travis/58231b16fdee45a03a4ee3cf94a9f2c3
- name: Set env variables
run: |
echo "TRAVIS_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
echo "TRAVIS_BUILD_NUMBER=$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "${{ github.event.head_commit.message }}"
echo "TRAVIS_COMMIT_MESSAGE=`git log -1 --pretty=format:"%s"`" >> $GITHUB_ENV
echo "REPO=`node -e 'console.log(require("${{ github.workspace }}/package.json").insights.buildrepo)'`" >> $GITHUB_ENV
- run: git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all
## pull build files
- run: mkdir ${{ github.workspace }}/scripts
- name: Pull release file
run: curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/release.sh > ${{ github.workspace }}/scripts/release.sh
- run: chmod +x "${{ github.workspace }}/scripts/release.sh"
- name: Pull nginx conf file
run: curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/nginx_conf_gen.sh > ${{ github.workspace }}/scripts/nginx_conf_gen.sh
- run: chmod +x "${{ github.workspace }}/scripts/nginx_conf_gen.sh"
- name: Pull quay push file
run: curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/quay_push.sh > ${{ github.workspace }}/scripts/quay_push.sh
- run: chmod +x "${{ github.workspace }}/scripts/quay_push.sh"
## set access to build repo
- name: Add SSH key
run: |
mkdir -p /home/runner/.ssh
ssh-keyscan github.com >> /home/runner/.ssh/known_hosts
echo "${{ secrets.BUILD_PRIVATE_KEY }}" > /home/runner/.ssh/github_actions
chmod 600 /home/runner/.ssh/github_actions
echo "Host github.com
HostName github.com
User git
AddKeysToAgent yes
IdentityFile /home/runner/.ssh/github_actions" >> /home/runner/.ssh/config
- uses: actions/download-artifact@v3
with:
name: build
path: ${{ github.workspace }}/dist/
- name: Check custom_release existence
id: check_custom_release
uses: andstor/file-existence-action@v1
with:
files: "custom_release.sh"
- name: Run default deploy
if: steps.check_custom_release.outputs.files_exists != 'true'
env:
APP_BUILD_DIR: ${{ github.workspace }}/dist
run: ${{ github.workspace }}/scripts/release.sh ${{ github.ref_name == 'main' && 'stage-beta' || github.ref_name }}
working-directory: ${{ github.workspace }}
- name: Run the deploy
if: steps.check_custom_release.outputs.files_exists == 'true'
run: ${{ github.workspace }}/custom_release.sh