Skip to content

Commit

Permalink
Updated actions
Browse files Browse the repository at this point in the history
* hashicorp/actions-docker-build v1.0.0 ==> v2.0.0
* hashicorp/actions-generate-metadata v1.0.0 ==> v1.1.1
* hashicorp/actions-go-build v0.1.9 ==> v1.0.0
* hashicorp/actions-slack-status v1.0.0 ==> v2.0.1
  • Loading branch information
angrycub committed Jun 11, 2024
1 parent 0bb0958 commit d4873e2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ on:
push:
workflow_dispatch:
workflow_call:

env:
PKG_NAME: "levant"

jobs:
get-go-version:
name: "Determine Go toolchain version"
Expand All @@ -18,6 +20,7 @@ jobs:
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
get-product-version:
runs-on: ubuntu-20.04
outputs:
Expand All @@ -29,6 +32,7 @@ jobs:
run: |
make version
echo "product-version=$(make version)" >> "$GITHUB_OUTPUT"
generate-metadata-file:
needs: get-product-version
runs-on: ubuntu-20.04
Expand All @@ -39,16 +43,18 @@ jobs:
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@v1
uses: hashicorp/actions-generate-metadata@fdbc8803a0e53bcbb912ddeee3808329033d6357 # v1.1.1
with:
version: ${{ needs.get-product-version.outputs.product-version }}
product: ${{ env.PKG_NAME }}
repository: ${{ env.PKG_NAME }}
repositoryOwner: "hashicorp"
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: ${{ !env.ACT }}
with:
name: metadata.json
path: ${{ steps.generate-metadata-file.outputs.filepath }}

generate-ldflags:
needs: get-product-version
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -88,7 +94,7 @@ jobs:
GO_LDFLAGS: ${{ needs.generate-ldflags.outputs.ldflags }}
CGO_ENABLED: "0"
BIN_PATH: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}
uses: hashicorp/actions-go-build@v0.1.9
uses: hashicorp/actions-go-build@37358f6098ef21b09542d84a9814ebb843aa4e3e # v1.0.0
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.get-product-version.outputs.product-version }}
Expand All @@ -99,7 +105,7 @@ jobs:
instructions: |-
make crt
- if: ${{ matrix.goos == 'linux' }}
uses: hashicorp/actions-packaging-linux@v1
uses: hashicorp/actions-packaging-linux@0596d94121d44bd00463ac9d245efea64ee282d0 # v1.7.0
with:
name: "levant"
description: "Levant is a templating and deployment tool for HashiCorp Nomad"
Expand Down Expand Up @@ -128,6 +134,7 @@ jobs:
name: ${{ env.DEB_PACKAGE }}
path: out/${{ env.DEB_PACKAGE }}
if-no-files-found: error

build-docker-default:
needs:
- get-product-version
Expand All @@ -143,7 +150,7 @@ jobs:
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Docker Build (Action)
uses: hashicorp/actions-docker-build@v1
uses: hashicorp/actions-docker-build@11d43ef520c65f58683d048ce9b47d6617893c9a # v2.0.0
with:
smoke_test: |
TEST_VERSION="$(docker run "${IMAGE_NAME}" version | awk '/Levant/{print $2}')"
Expand All @@ -160,5 +167,6 @@ jobs:
dev_tags: |
docker.io/hashicorppreview/${{ env.PKG_NAME }}:${{ env.version }}-dev
docker.io/hashicorppreview/${{ env.PKG_NAME }}:${{ env.version }}-${{ github.sha }}
permissions:
contents: read
17 changes: 14 additions & 3 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@
# notarized.
# Failures are reported to slack.
name: Nightly Release

on:
schedule:
# Runs against the default branch every day overnight
- cron: "18 3 * * *"

workflow_dispatch:

jobs:
# Build a fresh set of artifacts
build-artifacts:
uses: ./.github/workflows/build.yml

github-release:
needs: build-artifacts
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Download built artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
path: out/

# Set BUILD_OUTPUT_LIST to out\<project>-<version>.<fileext>\*,out\...
# This is needed to attach the build artifacts to the GitHub Release
- name: Set BUILD_OUTPUT_LIST
Expand All @@ -30,6 +36,7 @@ jobs:
sed 's:.*:out/&/*:' < tmp.txt > tmp2.txt
echo "BUILD_OUTPUT_LIST=$(tr '\n' ',' < tmp2.txt | perl -ple 'chop')" >> "$GITHUB_ENV"
rm -rf tmp.txt && rm -rf tmp2.txt
- name: Advance nightly tag
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
Expand All @@ -50,6 +57,7 @@ jobs:
ref: "refs/tags/nightly",
sha: context.sha
})
# This will create a new GitHub Release called `nightly`
# If a release with this name already exists, it will overwrite the existing data
- name: Create a nightly GitHub prerelease
Expand All @@ -65,26 +73,29 @@ jobs:
removeArtifacts: true
draft: false
token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish nightly GitHub prerelease
uses: eregon/publish-release@01df127f5e9a3c26935118e22e738d95b59d10ce # v1.0.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_prerelease.outputs.id }}
# Send a slack notification if either job defined above fails

# Send a slack notification if either job defined above fails
slack-notify:
needs:
- build-artifacts
- github-release
if: always() && (needs.build-artifacts.result == 'failure' || needs.github-release.result == 'failure')
runs-on: ubuntu-latest
steps:
- name: Notify Slack on failed Backport PRs
uses: hashicorp/actions-slack-status@v1
- name: Notify Slack on Nightly Release Failure
uses: hashicorp/actions-slack-status@1a3f63b30bd476aee1f3bd6f9d8f2aacc4f14d81 # v2.0.1
with:
failure-message: |-
:x::moon::nomad-sob: Levant Nightly Release *FAILED* on
status: failure
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}

permissions:
contents: write

0 comments on commit d4873e2

Please sign in to comment.