Skip to content

Commit

Permalink
Gh actions permissions (#1)
Browse files Browse the repository at this point in the history
* using two targets for middleman config

* updated permissions
  • Loading branch information
aaroncastro1990 authored Apr 12, 2024
1 parent da7db0f commit f95b7e1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- main
permissions:
contents: write
pages: write
env:
# HOME required by Setup Git and Setup Go Steps
HOME: ${{ github.workspace }}
Expand Down Expand Up @@ -97,12 +98,21 @@ jobs:
gem update --system 3.2.3
echo "Pull Request: $TRAVIS_PULL_REQUEST"
# Ensure the site builds, otherwise fail the build on PRs
if [[ $CI_NODE_INDEX = "build" && $TRAVIS_PULL_REQUEST != 'false' ]]; then bundle exec rake download_policy_list; bundle exec middleman build; fi
if [[ $CI_NODE_INDEX = "build" && $TRAVIS_PULL_REQUEST != 'false' ]]; then bundle exec rake download_policy_list; TARGET="test" bundle exec middleman build; fi
# Ensure the links work, otherwise fail the build on PRs (only on PRs)
if [[ $CI_NODE_INDEX = "check_links" && $TRAVIS_PULL_REQUEST != 'false' ]]; then echo "TODO Fix check_links to throttle itself properly"; fi
# Only deploy the site live if the master branch is updated (not during pull-requests)
# Currently, deploy first builds by default
if [[ $CI_NODE_INDEX = "build" && $TRAVIS_PULL_REQUEST == 'false' ]]; then bundle exec rake download_policy_list; bundle exec middleman deploy; fi
if [[ $CI_NODE_INDEX = "build" && $TRAVIS_PULL_REQUEST == 'false' ]]; then bundle exec rake download_policy_list; bundle exec middleman build; fi
env:
CI_NODE_INDEX: ${{ matrix.index }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to Github Pages
if: ${{env.CI_NODE_INDEX == 'build'}}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
env:
CI_NODE_INDEX: ${{ matrix.index }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 18 additions & 6 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,27 @@ def image(link, title, alt_text)
end

# middleman-deploy configuration
activate :deploy do |deploy|
# Automatically run `middleman build` during `middleman deploy`
deploy.build_before = true

# rsync, ftp, sftp, or git
deploy.method = :git
case ENV['TARGET'].to_s.downcase
when 'test'
activate :deploy do |deploy|
# Automatically run `middleman build` during `middleman deploy`
deploy.build_before = true

# rsync, ftp, sftp, or git
deploy.method = :git
deploy.branch = "test-gh-pages"
end
else
activate :deploy do |deploy|
# Automatically run `middleman build` during `middleman deploy`
deploy.build_before = true

# rsync, ftp, sftp, or git
deploy.method = :git
end
end


page "/release-feed.xml", :layout => false

# Activate middleman-breadcrumb gem
Expand Down

0 comments on commit f95b7e1

Please sign in to comment.