ci: bump actions/checkout from 4.2.0 to 4.2.1 (#52) #121
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: "Upload Chart" | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'heartex/**' | |
- '.github/workflows/publish.yml' | |
env: | |
HELM_CHARTS_BUCKET: "heartex-charts" | |
HELM_CHARTS_REPO: "https://charts.heartex.com" | |
SYNC_DIR: sync | |
INDEX_DIR: index | |
AWS_REGION: us-east-1 | |
jobs: | |
upload_chart: | |
name: "Upload Chart" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: hmarr/[email protected] | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: '2' | |
- name: Helm package | |
id: helm_package | |
run: | | |
set -eu | |
# gather only changed charts | |
CHANGED_CHARTS=$(git diff --dirstat=files,0 HEAD~1 -- heartex/ | sed -E 's/^[ 0-9.]+% //g' | cut -d'/' -f2- | cut -d'/' -f1 | sort -u) | |
echo "Changed charts:" | |
echo "$CHANGED_CHARTS" | |
CHANGED_CHARTS_MAP="" | |
for chart in $CHANGED_CHARTS; do | |
chart_version=$(cat heartex/$chart/Chart.yaml | yq eval '.version' -) | |
helm package ./heartex/$chart -d ${{ env.SYNC_DIR }} -u | |
CHANGED_CHARTS_MAP="${CHANGED_CHARTS_MAP}$chart => $chart_version\n" | |
done | |
echo "CHANGED_CHARTS_MAP<<EOF" >> $GITHUB_ENV | |
echo "${CHANGED_CHARTS_MAP}" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.CHARTS_UPLOAD_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.CHARTS_UPLOAD_AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Build helm index | |
id: helm_index | |
run: | | |
set -eux | |
aws s3 cp s3://${{ env.HELM_CHARTS_BUCKET }}/index.yaml "${{ env.INDEX_DIR }}/index.yaml" || true | |
helm repo index ${{ env.SYNC_DIR }} --url "${{ env.HELM_CHARTS_REPO }}" --merge "${{ env.INDEX_DIR }}/index.yaml" | |
echo "==> Merged index:" | |
cat "${{ env.SYNC_DIR }}/index.yaml" | |
- name: Publish to S3 | |
run: | | |
set -eux | |
aws s3 cp ${{ env.SYNC_DIR }} s3://${{ env.HELM_CHARTS_BUCKET }}/ --recursive | |
# Make sure index.yaml is synced last | |
aws s3 cp "${{ env.SYNC_DIR }}/index.yaml" s3://${{ env.HELM_CHARTS_BUCKET }}/ | |
- name: Post to a Slack channel | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
channel-id: 'C02LMULF4NA' | |
slack-message: "New versions of helm charts released:\n${{ env.CHANGED_CHARTS_MAP }}<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|[Workflow run]>" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |