Build #2
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: | |
tags: ["*"] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: [ ubuntu-latest ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
timeout-minutes: 15 | |
continue-on-error: true | |
with: | |
node-version: 18.16 | |
- name: Install bower | |
run: npm install -g bower | |
- name: Import PGP Key | |
run: | | |
export GPG_TTY=$(tty) | |
gpg --batch --import - <<< ${{ secrets.PGP_KEY }} | |
- name: Write version | |
id: version | |
run: | | |
V=$(sbt -no-colors --error "print version" | awk 'END{print $1}') | |
echo "version=$V" | |
echo "version=$V" >> $GITHUB_OUTPUT | |
- name: Build packages | |
run: sbt Docker/stage Debian/packageBin Rpm/packageBin Universal/packageBin cortexWithDeps/Docker/stage makeBom | |
- name: Move packages | |
run: | | |
mv target/rpm/RPMS/noarch/cortex*.rpm target/ | |
mv target/universal/cortex*.zip target/ | |
- name: Write docker tags from version | |
id: tags | |
run: | | |
V=${{ steps.version.outputs.version }} | |
if ( echo $V | grep -qi rc ) | |
then | |
echo $( echo $V | sed -re 's/([0-9]+.[0-9]+.[0-9]+)-RC([0-9]+)-([0-9]+)/\1-RC\2,\1-RC\2-\3/' ) > target/tags | |
else | |
echo $( echo $V | sed -re 's/([0-9]+).([0-9]+).([0-9]+)-([0-9]+)/\1,\1.\2,\1.\2.\3,\1.\2.\3-\4,latest/' ) > target/tags | |
fi | |
echo "tags=$(cat target/tags)" >> $GITHUB_OUTPUT | |
- name: Build list of additional tags | |
id: additional-tags | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
core.setOutput('tags', `${{ steps.tags.outputs.tags }}`.split(",").join("\n")) | |
- name: Generate full docker tags | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
name=${{ secrets.HARBOR_REGISTRY }}/thehiveproject/cortex | |
name=thehiveproject/cortex | |
tags: | | |
${{ steps.additional-tags.outputs.tags }} | |
- name: Login to Harbor | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.HARBOR_REGISTRY }} | |
username: ${{ secrets.HARBOR_USERNAME }} | |
password: ${{ secrets.HARBOR_PASSWORD }} | |
- name: Login to Dockerhub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push docker | |
uses: docker/build-push-action@v3 | |
with: | |
context: target/docker/stage | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: Build and push fat docker | |
uses: docker/build-push-action@v3 | |
with: | |
context: target/docker-withdeps/target/docker/stage | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: Make github release | |
uses: "softprops/action-gh-release@v1" | |
id: make-release | |
with: | |
generate_release_notes: true | |
files: | | |
target/cortex*.deb | |
target/cortex*.rpm | |
target/cortex*.zip | |
target/cortex*.bom.xml | |
notify: | |
needs: [ build ] | |
runs-on: [ ubuntu-latest ] | |
if: always() | |
steps: | |
- name: Slack notification | |
uses: Gamesight/slack-workflow-status@master | |
with: | |
repo_token: ${{secrets.GITHUB_TOKEN}} | |
slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} | |
channel: "#ci-cortex" | |
name: Cortex build | |
include_commit_message: true | |
include_jobs: true |