From ab8015a4d8849c3da662b8a739e3e72dfa2fdd35 Mon Sep 17 00:00:00 2001 From: Eric Knibbe Date: Fri, 13 Sep 2019 04:33:39 -0400 Subject: [PATCH] Migrate data generation workflow to YAML (#44203) --- .github/main.workflow | 10 ---- .github/main.workflow.sh | 59 ------------------- .../generate_formulae.brew.sh_data.yml | 42 +++++++++++++ 3 files changed, 42 insertions(+), 69 deletions(-) delete mode 100644 .github/main.workflow delete mode 100755 .github/main.workflow.sh create mode 100644 .github/workflows/generate_formulae.brew.sh_data.yml diff --git a/.github/main.workflow b/.github/main.workflow deleted file mode 100644 index b783ac8b3a..0000000000 --- a/.github/main.workflow +++ /dev/null @@ -1,10 +0,0 @@ -workflow "Push" { - on = "push" - resolves = ["Generate formulae.brew.sh"] -} - -action "Generate formulae.brew.sh" { - uses = "docker://linuxbrew/brew" - runs = ".github/main.workflow.sh" - secrets = ["ANALYTICS_JSON_KEY", "FORMULAE_DEPLOY_KEY"] -} diff --git a/.github/main.workflow.sh b/.github/main.workflow.sh deleted file mode 100755 index 894e7e0b6d..0000000000 --- a/.github/main.workflow.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -set -e - -# silence bundler complaining about being root -mkdir ~/.bundle -echo 'BUNDLE_SILENCE_ROOT_WARNING: "1"' > ~/.bundle/config - -# configure git -git config --global user.name "BrewTestBot" -git config --global user.email "homebrew-test-bot@lists.sfconservancy.org" - -# create stubs so build dependencies aren't incorrectly flagged as missing -for i in python svn unzip xz -do - touch /usr/bin/$i - chmod +x /usr/bin/$i -done - -# setup Homebrew/homebrew-core instead of Linuxbrew's -CORE_DIR="$(brew --repo homebrew/core)" -mkdir -p "$CORE_DIR" -rm -rf "$CORE_DIR" -ln -s "$PWD" "$CORE_DIR" - -# get latest Homebrew/homebrew-core -git -C "$CORE_DIR" fetch -git -C "$CORE_DIR" checkout -f master -git -C "$CORE_DIR" reset --hard origin/master - -# setup Homebrew environment -export HOMEBREW_NO_AUTO_UPDATE=1 -export HOMEBREW_NO_ANALYTICS=1 -export HOMEBREW_FORCE_HOMEBREW_ON_LINUX=1 -export PATH="$(brew --repo)/Library/Homebrew/vendor/portable-ruby/current/bin:$PATH" - -# setup SSH -mkdir ~/.ssh -chmod 700 ~/.ssh -echo "$FORMULAE_DEPLOY_KEY" > ~/.ssh/id_ed25519 -chmod 600 ~/.ssh/id_ed25519 -git config --global core.sshCommand "ssh -i ~/.ssh/id_ed25519 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" - -# clone formulae.brew.sh with SSH so we can push back -git clone git@github.com:Homebrew/formulae.brew.sh -cd formulae.brew.sh - -# setup analytics -echo "$ANALYTICS_JSON_KEY" > ~/.homebrew_analytics.json -unset HOMEBREW_NO_ANALYTICS - -# run rake (without a rake binary) -ruby -e "load Gem.bin_path('rake', 'rake')" - -# commit and push generated files -git add _data/formula api/formula formula -git diff --exit-code HEAD -- _data/analytics _data/formula api/formula formula cask && exit 0 -git commit -m 'formula: update from Homebrew/homebrew-core push' _data/analytics _data/formula api/formula formula -git push diff --git a/.github/workflows/generate_formulae.brew.sh_data.yml b/.github/workflows/generate_formulae.brew.sh_data.yml new file mode 100644 index 0000000000..5ea160c3fd --- /dev/null +++ b/.github/workflows/generate_formulae.brew.sh_data.yml @@ -0,0 +1,42 @@ +name: Generate formulae.brew.sh data. + +on: + push: + branches: + - master + +jobs: + generate: + runs-on: macos-latest + steps: + - uses: actions/checkout@master + - uses: Homebrew/actions/git-ssh@master + with: + git_user: BrewTestBot + git_email: homebrew-test-bot@lists.sfconservancy.org + key: ${{ secrets.FORMULAE_DEPLOY_KEY }} + - run: | + brew update-reset "$(brew --repository)" + brew tap "$GITHUB_REPOSITORY" + brew update-reset "$(brew --repository "$GITHUB_REPOSITORY")" + + export PATH="$(brew --repo)/Library/Homebrew/vendor/portable-ruby/current/bin:$PATH" + + git clone --depth=1 git@github.com:Homebrew/formulae.brew.sh + cd formulae.brew.sh + + # setup analytics + echo "$ANALYTICS_JSON_KEY" > ~/.homebrew_analytics.json + + # run rake (without a rake binary) + ruby -e "load Gem.bin_path('rake', 'rake')" + + # commit and push generated files + git add _data/formula api/formula formula + + if ! git diff --exit-code HEAD -- _data/analytics _data/formula api/formula formula cask; then + git commit -m "formula: update from ${GITHUB_REPOSITORY} push" _data/analytics _data/formula api/formula formula + git push + fi + env: + ANALYTICS_JSON_KEY: ${{ secrets.ANALYTICS_JSON_KEY }}