Skip to content

Fix Multi-line InitSQL Support for AWS RDS Postgres (#69) #212

Fix Multi-line InitSQL Support for AWS RDS Postgres (#69)

Fix Multi-line InitSQL Support for AWS RDS Postgres (#69) #212

Workflow file for this run

name: Build GitHub Actions Staging Image (Blacksmith Optimized)
on:
push:
branches:
- staging
workflow_dispatch:
jobs:
build-staging:
name: Build Staging Image
runs-on: blacksmith-32vcpu-ubuntu-2204
outputs:
cicd-bot-telegram-token: ${{ steps.prepare-additional-secrets.outputs.cicd-bot-telegram-token }}
cicd-bot-telegram-chat-id: ${{ steps.prepare-additional-secrets.outputs.cicd-bot-telegram-chat-id }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go with Blacksmith caching
uses: useblacksmith/setup-go@v6
with:
go-version: '1.24'
- name: Set version for build
run: |
VERSION="staging-${{ github.run_number }}-$(date -u +%Y%m%d-%H%M%S)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "🏷️ Set VERSION: $VERSION"
- name: Cache CLI tools (SC + Welder)
uses: actions/cache@v4 # Automatically uses Blacksmith cache on Blacksmith runners
with:
path: |
~/.local/bin/sc
~/.local/bin/welder
key: cli-tools-${{ runner.os }}-v1
restore-keys: |
cli-tools-${{ runner.os }}-
- name: Install CLI tools
run: |
# Install SC CLI if not cached
if ! command -v sc &> /dev/null; then
echo "Installing Simple Container CLI..."
curl -s "https://dist.simple-container.com/sc.sh" | bash
else
echo "βœ… SC CLI already cached and available"
fi
# Install Welder if not cached
if ! command -v welder &> /dev/null; then
echo "Installing Welder..."
curl -Ls "https://welder.simple-container.com/welder.sh" | bash
else
echo "βœ… Welder already cached and available"
fi
- name: Prepare secrets for build
run: |
cat << EOF > ./.sc/cfg.default.yaml
${{ secrets.SC_CONFIG }}
EOF
cat << EOF > ./.sc/cfg.test.yaml
${{ secrets.SC_CONFIG }}
EOF
sc secrets reveal
- name: Prepare additional secrets for notifications
id: prepare-additional-secrets
run: |
echo "cicd-bot-telegram-token=$(sc stack secret-get -s dist cicd-bot-telegram-token)" >> $GITHUB_OUTPUT
echo "cicd-bot-telegram-chat-id=$(sc stack secret-get -s dist cicd-bot-telegram-chat-id)" >> $GITHUB_OUTPUT
- name: Setup Docker Buildx with advanced caching
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:buildx-stable-1
buildkitd-flags: --allow-insecure-entitlement security.insecure
- name: Build static github-actions binary with welder (cached Go modules)
run: |
echo "Building with VERSION: $VERSION"
welder run build-github-actions-staging
- name: Docker login using SC secrets
run: |
sc stack secret-get -s dist dockerhub-cicd-token | docker login --username simplecontainer --password-stdin
- name: Build and push Docker image with BuildKit caching
env:
DOCKER_BUILDKIT: 1
run: |
# Build and push with advanced caching using BuildKit
docker buildx build \
--platform linux/amd64 \
--cache-from type=gha \
--cache-to type=gha,mode=max \
--file github-actions-staging.Dockerfile \
--tag simplecontainer/github-actions:staging \
--tag simplecontainer/github-actions:${{ github.ref_name }} \
--push \
.
- name: Image built successfully
run: |
echo "πŸŽ‰ GitHub Actions staging image built successfully with BuildKit + GitHub Actions caching!"
echo ""
echo "πŸš€ The staging image is now available:"
echo " simplecontainer/github-actions:staging"
echo " simplecontainer/github-actions:${{ github.ref_name }}"
echo ""
echo "πŸ“¦ Built with version: $VERSION"
echo "βœ… Your GitHub Actions will now use the updated staging image with your latest changes!"
echo "⚑ Build was accelerated using:"
echo " β€’ Blacksmith runner caching (Go modules, CLI tools)"
echo " β€’ Docker BuildKit layer caching (GitHub Actions cache)"
echo " β€’ Multi-platform optimized build"
echo ""
echo "πŸ“ Next steps:"
echo " 1. Test your GitHub Actions workflows"
echo " 2. Push changes to main when ready for production"
finalize:
name: Finalize staging build
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- build-staging
steps:
- uses: actions/checkout@v4
if: ${{ always() }}
- name: Extract git reference
id: extract_git_ref
if: ${{ always() }}
shell: bash
run: |-
cat <<'EOF' > /tmp/commit_message.txt
${{ github.event.head_commit.message || github.event.workflow_run.head_commit.message }}
EOF
message="$(cat /tmp/commit_message.txt | tr -d '\n')"
echo "branch=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
echo "message=$message" >> $GITHUB_OUTPUT
echo "author=$GITHUB_ACTOR" >> $GITHUB_OUTPUT
echo "url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT
# Notify telegram on success
- uses: yanzay/notify-telegram@v0.1.0
if: ${{ success() && !contains(needs.*.result, 'failure') }}
continue-on-error: true
with:
chat: ${{ needs.build-staging.outputs.cicd-bot-telegram-chat-id }}
token: ${{ needs.build-staging.outputs.cicd-bot-telegram-token }}
status: βœ… staging build success (${{ steps.extract_git_ref.outputs.branch }}) - ${{ steps.extract_git_ref.outputs.message }} by ${{ steps.extract_git_ref.outputs.author }}
# Notify telegram on failure
- uses: yanzay/notify-telegram@v0.1.0
if: ${{ failure() || contains(needs.*.result, 'failure') }}
continue-on-error: true
with:
chat: ${{ needs.build-staging.outputs.cicd-bot-telegram-chat-id }}
token: ${{ needs.build-staging.outputs.cicd-bot-telegram-token }}
status: ❗ staging build failure (${{ steps.extract_git_ref.outputs.branch }}) - ${{ steps.extract_git_ref.outputs.message }} by ${{ steps.extract_git_ref.outputs.author }}
- name: Build failed due to previously failed steps
id: fail_if_needed
if: ${{ failure() || contains(needs.*.result, 'failure') }}
shell: bash
run: |-
exit 1