From 07392b2948c7373af4ee7defd61df2f2f7d96229 Mon Sep 17 00:00:00 2001 From: Oleg Barenboim Date: Tue, 8 Feb 2022 16:25:31 -0500 Subject: [PATCH] Switch to GitHub Actions --- .github/workflows/deploy.yaml | 30 +++++++++++++++++++++++++++ .travis.yml | 28 ------------------------- deploy.sh | 6 +++--- parse_commit_message.rb | 10 +++++++++ trigger.sh | 39 ----------------------------------- 5 files changed, 43 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/deploy.yaml delete mode 100644 .travis.yml create mode 100755 parse_commit_message.rb delete mode 100755 trigger.sh diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000000..817be2dd57 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,30 @@ +name: Build +on: + repository_dispatch: + types: [deploy] +jobs: + deploy: + runs-on: ubuntu-latest + env: + JEKYLL_ENV: production + MIQ_ENV: production + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PAYLOAD_REF: ${{ github.event.client_payload.ref }} + PAYLOAD_SHA: ${{ github.event.client_payload.sha }} + PAYLOAD_REPOSITORY: ${{ github.event.client_payload.repository }} + PAYLOAD_COMMIT_MESSAGE: ${{ github.event.client_payload.commit_message }} + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.5' + bundler-cache: true + - name: Get manageiq.org repo + run: git clone https://github.com/ManageIQ/manageiq.org + - name: Build + run: cd manageiq.org & exe/miq build all + - name: Set COMMIT_MESSAGE + run: parse_commit_message.rb >> $GITHUB_ENV + - name: Deploy + run: deploy.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a0650ec814..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: ruby -rvm: 2.5.6 -env: - global: - - JEKYLL_ENV=production - - MIQ_ENV=production - - BUNDLE_PATH=${TRAVIS_BUILD_DIR}/vendor/bundle -cache: - directories: - - ${TRAVIS_BUILD_DIR}/vendor/bundle -before_install: -- git clone https://github.com/ManageIQ/manageiq.org -- cd manageiq.org -script: -- "exe/miq build all" -deploy: - provider: script - skip_cleanup: true - script: ${TRAVIS_BUILD_DIR}/deploy.sh - on: - branch: build -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/bccd4e19564e564508d1 - on_success: change - on_failure: always - on_start: never diff --git a/deploy.sh b/deploy.sh index 4e2e8dd860..6831fde1a5 100755 --- a/deploy.sh +++ b/deploy.sh @@ -2,15 +2,15 @@ set -x -cd dest +cd manageiq.org/dest echo "www.manageiq.org" > CNAME git config --global user.name "ManageIQ Bot" git config --global user.email "noreply@manageiq.org" -git clone --bare --branch master --depth 5 https://miq-bot:${GITHUB_TOKEN}@github.com/ManageIQ/manageiq.github.io .git +git clone --bare --branch master --depth 5 https://x-access-token:${GITHUB_TOKEN}@github.com/ManageIQ/manageiq.github.io .git git config core.bare false git add -A -git commit -m "${TRAVIS_COMMIT_MESSAGE}" +git commit -m "${COMMIT_MESSAGE}" git push origin master diff --git a/parse_commit_message.rb b/parse_commit_message.rb new file mode 100755 index 0000000000..6ffba0e9ab --- /dev/null +++ b/parse_commit_message.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +message = + if ENV["PAYLOAD_COMMIT_MESSAGE"].to_s =~ /\AMerge pull request (#\d+)/ + "#{ENV["PAYLOAD_REPOSITORY"]}#{\$1}" + else + "#{ENV["PAYLOAD_REPOSITORY"]}@#{ENV["PAYLOAD_SHA"]} (#{ENV["PAYLOAD_REF"]})" + end + +puts "COMMIT_MESSAGE=\"#{message}\"" diff --git a/trigger.sh b/trigger.sh deleted file mode 100755 index f2057db011..0000000000 --- a/trigger.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -cat << RUBY | ruby -r json -source = - if ENV["TRAVIS_COMMIT_MESSAGE"].to_s =~ /\AMerge pull request (#\d+)/ - "#{ENV["TRAVIS_REPO_SLUG"]}#{\$1}" - else - "#{ENV["TRAVIS_REPO_SLUG"]}@#{ENV["TRAVIS_COMMIT"]} (#{ENV["TRAVIS_BRANCH"]})" - end - -user_name, user_email, commit_message = - \`git log -1 --pretty=format:"%aN%x00%aE%x00%B"\`.split("\0") - -File.write("/tmp/post.json", { - "request" => { - "branch" => "build", - "message" => "Deployed site for #{source}", - "config" => { - "merge_mode" => "deep_merge", - "env" => { - "global" => [ - "SOURCE_REPO_INFO" => source, - "SOURCE_USER_NAME" => user_name, - "SOURCE_USER_EMAIL" => user_email, - "SOURCE_COMMIT_MESSAGE" => commit_message, - ] - } - } - } -}.to_json) -RUBY - -curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "Accept: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Authorization: token $TRAVIS_TOKEN" \ - -d @/tmp/post.json \ - https://api.travis-ci.com/repo/ManageIQ%2Fmanageiq.github.io/requests