Skip to content

Add workflow for e2e init tests #73

Add workflow for e2e init tests

Add workflow for e2e init tests #73

name: Zarf Injector Update
on:
pull_request:
branches:
- "main"
workflow_dispatch:
jobs:
update-injector-version:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
if: github.actor == 'renovate[bot]' || github.event_name == 'workflow_dispatch' # Only run if the actor is Renovate bot or if manually triggered
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Log zarf-config.yaml contents
run: |
echo "Logging contents of zarf-config.yaml:"
cat zarf-config.yaml
- name: Extract Zarf version (agent_image_tag)
id: zarf_version
run: |
zarf_version=$(grep 'agent_image_tag:' zarf-config.yaml | awk '{print $2}' | tr -d ' ')
if [ -z "$zarf_version" ]; then
echo "Error: Zarf version (agent_image_tag) not found in zarf-config.yaml"
exit 1
fi
echo "Zarf Release Version: $zarf_version"
echo "zarf_version=$zarf_version" >> $GITHUB_ENV
- name: Clone zarf-dev repository and checkout version
run: |
git clone https://github.com/zarf-dev/zarf.git
cd zarf
git fetch --all --tags
if git rev-parse "${{ env.zarf_version }}" >/dev/null 2>&1; then
git checkout "${{ env.zarf_version }}"
else
echo "Error: Release version ${{ env.zarf_version }} not found in zarf-dev repository."
exit 1
fi
cp zarf-config.toml ../
cd ..
- name: Parse and update zarf-config.yaml
run: |
# Extract values from the zarf-config.toml file
version=$(grep 'injector_version =' zarf-config.toml | cut -d"'" -f2)
amd64_shasum=$(grep 'injector_amd64_shasum =' zarf-config.toml | cut -d"'" -f2)
arm64_shasum=$(grep 'injector_arm64_shasum =' zarf-config.toml | cut -d"'" -f2)
# Log extracted values (optional for debugging)
echo "Injector Version: $version"
echo "Injector AMD64 SHA: $amd64_shasum"
echo "Injector ARM64 SHA: $arm64_shasum"
# Update the local zarf-config.yaml file with these values
sed -i "s/injector_version: .*/injector_version: \"$version\"/" zarf-config.yaml
sed -i "s/injector_amd64_shasum: .*/injector_amd64_shasum: $amd64_shasum/" zarf-config.yaml
sed -i "s/injector_arm64_shasum: .*/injector_arm64_shasum: $arm64_shasum/" zarf-config.yaml
- name: Check for changes
id: git_status
run: |
if git diff --quiet; then
echo "No changes detected."
echo "changes=false" >> $GITHUB_ENV
else
echo "Changes detected."
git diff
echo "changes=true" >> $GITHUB_ENV
fi
- name: Sign and push changes using graphql
if: env.changes == 'true'
uses: planetscale/[email protected]
with:
commit_message: "Update Zarf injector version and shasums from upstream"
repo: ${{ github.repository }}
branch: ${{ github.head_ref || github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
report-status:
needs:
- update-injector-version
permissions:
statuses: write
runs-on: ubuntu-latest
if: always() # This job will run regardless of whether update-injector-version runs or its result
steps:
- name: Determine status
id: determine_status
run: |
if [[ "${{ needs.update-injector-version.result }}" == "success" ]]; then
echo "STATUS=success" >> $GITHUB_ENV
echo "DESCRIPTION=Zarf injector updates completed successfully" >> $GITHUB_ENV
elif [[ "${{ needs.update-injector-version.result }}" == "skipped" ]]; then
echo "STATUS=success" >> $GITHUB_ENV
echo "DESCRIPTION=Zarf injector update was skipped - not a Renovate PR" >> $GITHUB_ENV
else
echo "STATUS=failure" >> $GITHUB_ENV
echo "DESCRIPTION=Zarf injector update failed" >> $GITHUB_ENV
fi
- name: Report status
uses: defenseunicorns/delivery-github-actions-workflows/.github/actions/report-status-context@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
status-check: "Zarf Injector check"
status: ${{ env.STATUS }}
description: ${{ env.DESCRIPTION }}