Move policy back to workstations #1
Workflow file for this run
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: Validate fleetd base checksums | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # Runs every 24 hours | ||
workflow_dispatch: # Allows manual trigger | ||
jobs: | ||
check-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Install dependencies | ||
run: sudo apt-get update | ||
- name: Download files from Cloudflare R2 | ||
env: | ||
R2_ACCESS_KEY: ${{ secrets.R2_ACCESS_KEY }} | ||
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }} | ||
R2_BUCKET: your-r2-bucket-name | ||
R2_REGION: your-r2-region | ||
run: | | ||
mkdir -p downloads | ||
cat << 'EOF' > download_files.sh | ||
#!/bin/bash | ||
set -e | ||
ENDPOINT_URL="https://<R2_ENDPOINT_URL>" | ||
FILES=("fleetd-base-manifest.plist" "fleetd-base.msi" "fleetd-base.pkg" "meta.json") | ||
for FILE in "${FILES[@]}"; do | ||
aws s3 cp s3://$R2_BUCKET/$FILE downloads/$FILE --endpoint-url $ENDPOINT_URL | ||
done | ||
EOF | ||
chmod +x download_files.sh | ||
./download_files.sh | ||
- name: Validate checksums | ||
run: | | ||
cat << 'EOF' > validate_checksums.sh | ||
#!/bin/bash | ||
set -e | ||
validate_checksum() { | ||
local file_path=$1 | ||
local expected_checksum=$2 | ||
local actual_checksum=$(shasum -a 256 "$file_path" | awk '{ print $1 }') | ||
if [ "$actual_checksum" != "$expected_checksum" ]; then | ||
echo "Checksum mismatch for $file_path: expected $expected_checksum, got $actual_checksum" | ||
return 1 | ||
fi | ||
} | ||
declare -A checksums | ||
checksums["downloads/fleetd-base-manifest.plist"]="expected_checksum_1" | ||
checksums["downloads/fleetd-base.msi"]="expected_checksum_2" | ||
checksums["downloads/fleetd-base.pkg"]="expected_checksum_3" | ||
checksums["downloads/meta.json"]="expected_checksum_4" | ||
all_valid=true | ||
for file_path in "${!checksums[@]}"; do | ||
expected_checksum=${checksums[$file_path]} | ||
if ! validate_checksum "$file_path" "$expected_checksum"; then | ||
all_valid=false | ||
fi | ||
done | ||
if [ "$all_valid" = false ]; then | ||
exit 1 | ||
fi | ||
EOF | ||
chmod +x validate_checksums.sh | ||
./validate_checksums.sh | ||
- name: Notify Slack on failure | ||
if: failure() | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
run: | | ||
curl -X POST -H 'Content-type: application/json' --data '{"text":"File validation failed in the GitHub workflow!"}' $SLACK_WEBHOOK_URL |