Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Refine actions
Browse files Browse the repository at this point in the history
- new on-commits.yml
- renamed main.yaml to on-tags.yml
- attempt to make addblob.sh idempotent
  • Loading branch information
gberche-orange committed Sep 25, 2023
1 parent d4bf1b3 commit 4fb8a4f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/on-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build-and-release

on:
push:

jobs:
build:
runs-on: ubuntu-latest
container:
image: orangeopensource/bosh-release-action:v5
# FIXME: change entry point
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: vendor-add-blob
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_BOSH_ACCES_KEY_ID: ${{ secrets.AWS_BOSH_ACCES_KEY_ID }}
AWS_BOSH_SECRET_ACCES_KEY: ${{ secrets.AWS_BOSH_SECRET_ACCES_KEY }}

with:
entrypoint: cat # avoid running the default entrypoint which tries to execute the bosh-release-action script
run: |
set -x # enable traces
# configure git
git config --global user.name "actions/k3s-boshrelease"
git config --global user.email "<>"
git config --global --add safe.directory /github/workspace
export VENDIR_GITHUB_API_TOKEN="${GITHUB_TOKEN}"
./vendor.sh
git add vendir.lock
# FIXME: optimize for idem potentency
./addblob.sh
git add config/blobs.yaml
git commit -a -m "updating blobs"
remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
git push ${remote_repo} HEAD:main

File renamed without changes.
26 changes: 21 additions & 5 deletions addblob.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
#!/bin/bash
set -x
bosh add-blob src/github.com/k3s-io/k3s/k3s k3s/k3s
bosh add-blob src/github.com/k3s-io/k3s/k3s-airgap-images-amd64.tar k3s-images/k3s-airgap-images-amd64.tar

# params
# $1: src
# $2: target
function addBlobOnChecksumChange() {
src="$1"
target="$2"
blob_checksum=$(cat config/blobs.yml | yq ."${src}".sha)
src_checksum=$(cat "${src}" | sha256sum | cut -d " " -f1)
if [ "${blob_checksum}" != "${src_checksum}" ]; then
bosh add-blob ${src} ${target}
else
echo "skipping blob creation with exiting checksum: ${src_checksum}"
fi
}

addBlobOnChecksumChange src/github.com/k3s-io/k3s/k3s k3s/k3s
addBlobOnChecksumChange src/github.com/k3s-io/k3s/k3s-airgap-images-amd64.tar k3s-images/k3s-airgap-images-amd64.tar


pushd src/github.com/derailed/k9s/
tar xfv ./k9s_Linux_amd64.tar.gz
popd


bosh add-blob src/github.com/derailed/k9s/k9s k9s/k9s
addBlobOnChecksumChange src/github.com/derailed/k9s/k9s k9s/k9s

pushd src/github.com/containerd/nerdctl/
tar xfv ./nerdctl-1.3.1-linux-amd64.tar.gz
popd

bosh add-blob src/github.com/containerd/nerdctl/nerdctl nerdctl/nerdctl
addBlobOnChecksumChange src/github.com/containerd/nerdctl/nerdctl nerdctl/nerdctl

pushd src
curl -LO https://dl.k8s.io/release/v1.24.9/bin/linux/amd64/kubectl --output ./src/kubectl
chmod ugo+x kubectl
popd
bosh add-blob src/kubectl kubectl/kubectl
addBlobOnChecksumChange src/kubectl kubectl/kubectl


0 comments on commit 4fb8a4f

Please sign in to comment.