Skip to content

Commit

Permalink
CHEF-13373 CI Pipeline modifications for multichannel support (builder)
Browse files Browse the repository at this point in the history
Provides a new GitHub workflow and its supporting actions to publish builder's habitat packages.  The hab pkg happens is trigger push to main and is limited to the packages altered in a given commit.

Signed-off-by: Jason Heath <[email protected]>
  • Loading branch information
jasonheath committed Jul 19, 2024
1 parent 1846817 commit c1b8db8
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/actions/hab-install-linux/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Habitat Install and Setup for Linux
description: Install Habitat via curl bash on linux hosts
inputs:
hab-auth-token:
description: The HAB_AUTH_TOKEN to be used
required: true
hab-origin:
description: The Habitat Origin to be used
required: true
curl-bash-url:
description: URL for the habitat curl bash script
required: true
default: 'https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh'
habitat-version:
description: Which version of habitat to use
required: true
default: latest
habitat-target:
description: Which architecture to target
required: true
default: x86_64-linux
runs:
using: composite
steps:

- name: install hab binary
shell: bash
env:
URL: ${{ inputs.curl-bash-url }}
VERSION: ${{ inputs.habitat-version }}
TARGET: ${{ inputs.habitat-target }}
run: |
curl "$URL" | sudo bash -s -- -v "$VERSION" -t "$TARGET"
- name: accept hab license
shell: bash
run: |
hab license accept
sudo hab license accept
- name: download hab keys
shell: bash
env:
HAB_ORIGIN: ${{ inputs.hab-origin }}
HAB_AUTH_TOKEN: ${{ inputs.hab-auth-token }}
run: |
hab origin key download $HAB_ORIGIN
hab origin key download $HAB_ORIGIN --auth $HAB_AUTH_TOKEN --secret
sudo hab origin key download $HAB_ORIGIN
sudo hab origin key download $HAB_ORIGIN --auth $HAB_AUTH_TOKEN --secret
35 changes: 35 additions & 0 deletions .github/actions/hab-pkg-build-and-upload-linux/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Habitat Package Build, Install, and Upload
description: Builds a Habitat Package and uploads it
inputs:
hab-auth-token:
description: The HAB_AUTH_TOKEN to be usAd
required: true
bldr-component:
description: The Builder Component to build and package
required: true
runs:
using: composite
steps:

- name: hab pkg build
shell: bash
env:
BLDR_COMPONENT: ${{ inputs.bldr-component }}
run: |
hab pkg build $BLDR_COMPONENT
- name: hab pkg install
shell: bash
env:
HAB_AUTH_TOKEN: ${{ inputs.hab-auth-token }}
run: |
source results/last_build.env
sudo hab pkg install --auth $HAB_AUTH_TOKEN results/$pkg_artifact
- name: hab pkg upload
shell: bash
env:
HAB_AUTH_TOKEN: ${{ inputs.hab-auth-token }}
run: |
source results/last_build.env
hab pkg upload --auth $HAB_AUTH_TOKEN results/$pkg_artifact
63 changes: 63 additions & 0 deletions .github/workflows/hab-pkg-build-upload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish Habitat Packages

on:
push:
branches:
- main

env:
BLDR_URL: 'https://bldr.habitat.sh/'
HAB_ORIGIN: 'habitat'
HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }}
HABITAT_VERSION_SET: 'latest'

permissions:
contents: write

jobs:

changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
components: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
builder-memcached:
- 'components/builder-memcached/**'
builder-minio:
- 'components/builder-minio/**'
builder-datastore:
- 'components/builder-datastore/**'
builder-api:
- 'components/builder-api/**'
builder-api-proxy:
- 'components/builder-api-proxy/**'
habitat-packaging:
needs: changes
if: ${{ needs.changes.outputs.components != '[]' && needs.changes.outputs.components != '' }}
name: ${{matrix.components}}
strategy:
fail-fast: false
matrix:
components: ${{ fromJSON(needs.changes.outputs.components) }}
runs-on: ubuntu-latest
steps:
- name: Checkout for ${{matrix.components}}
uses: actions/checkout@v4
- name: Install Habitat for ${{matrix.components}}
uses: ./.github/actions/hab-install-linux
with:
hab-auth-token: ${{ env.HAB_AUTH_TOKEN }}
hab-origin: ${{ env.HAB_ORIGIN }}
- name: Build and Upload Habitat Package for ${{matrix.components}}
uses: ./.github/actions/hab-pkg-build-and-upload-linux
with:
hab-auth-token: ${{ env.HAB_AUTH_TOKEN }}
bldr-component: components/${{matrix.components}}

0 comments on commit c1b8db8

Please sign in to comment.