├── .github ├── release-drafter.yml └── workflows │ └── release-management.yml ├── .gitignore ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── action.rb ├── action.yml └── entrypoint.sh /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | template: | 2 | ## What’s Changed 3 | $CHANGES 4 | -------------------------------------------------------------------------------- /.github/workflows/release-management.yml: -------------------------------------------------------------------------------- 1 | name: Release Management 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - master 8 | 9 | jobs: 10 | update_draft_release: 11 | runs-on: ubuntu-latest 12 | steps: 13 | # Drafts your next Release notes as Pull Requests are merged into "master" 14 | - uses: toolmantim/release-drafter@v5.2.0 15 | env: 16 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /spec/examples.txt 9 | /test/tmp/ 10 | /test/version_tmp/ 11 | /tmp/ 12 | 13 | # Used by dotenv library to load environment variables. 14 | # .env 15 | 16 | ## Specific to RubyMotion: 17 | .dat* 18 | .repl_history 19 | build/ 20 | *.bridgesupport 21 | build-iPhoneOS/ 22 | build-iPhoneSimulator/ 23 | 24 | ## Specific to RubyMotion (use of CocoaPods): 25 | # 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 29 | # 30 | # vendor/Pods/ 31 | 32 | ## Documentation cache and generated files: 33 | /.yardoc/ 34 | /_yardoc/ 35 | /doc/ 36 | /rdoc/ 37 | 38 | ## Environment normalization: 39 | /.bundle/ 40 | /vendor/bundle 41 | /lib/bundler/man/ 42 | 43 | # for a library or gem, you might want to ignore these files since the code is 44 | # intended to run in multiple environments; otherwise, check them in: 45 | # Gemfile.lock 46 | # .ruby-version 47 | # .ruby-gemset 48 | 49 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 50 | .rvmrc 51 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM andrius/alpine-ruby 2 | 3 | ENV RUBY_PACKAGES bash curl-dev ruby-dev build-base git ruby ruby-io-console ruby-bundler ruby-json ruby-rdoc 4 | 5 | # Update and install all of the required packages. 6 | # At the end, remove the apk cache 7 | RUN apk update && \ 8 | apk upgrade && \ 9 | apk add $RUBY_PACKAGES && \ 10 | rm -rf /var/cache/apk/* 11 | 12 | COPY entrypoint.sh /entrypoint.sh 13 | COPY action.rb /action.rb 14 | COPY Gemfile /Gemfile 15 | 16 | RUN chmod +x /entrypoint.sh 17 | RUN bundle install 18 | 19 | ENTRYPOINT ["/entrypoint.sh"] 20 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' do 2 | gem 'marky_markdown', '~> 0.2.2' 3 | end 4 | 5 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | marky_markdown (0.2.2) 5 | 6 | PLATFORMS 7 | ruby 8 | 9 | DEPENDENCIES 10 | marky_markdown (~> 0.2.2)! 11 | 12 | BUNDLED WITH 13 | 2.0.2 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Brian Douglas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Variables in Markdown 2 | This GitHub Action will allow you to set variables in Markdown and interpolate throughout your GitHub Issue. 3 | 4 | ## Usage 5 | 6 | This GitHub Action that replaces template in your variables 7 | 8 | ```yml 9 | on: issues 10 | name: Template Variables in Markdown 11 | jobs: 12 | markdown: 13 | name: markdown-marker 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@master 17 | - uses: bdougie/variables-in-markdown@master 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | 21 | ``` 22 | ## Testing 23 | 24 | This action is best used with issue templates. Create an example `.github/ISSUE_TEMPLATE.md` file. This file should have front matter to help construct the new issue: 25 | 26 | ```markdown 27 | --- 28 | title: New Issue 29 | labels: bug, enhancement 30 | --- 31 | 35 | 36 | "Say hi to your {{ NOUN }} for me," {{ ATTRIBUTION }} 37 | ``` 38 | 39 | You'll notice that the above example has some `{{ MUSTACHE }}` variables. This is needed for the API to find and replace variables. This is powered by the [marky_markdown](https://rubygems.org/gems/marky_markdown) ruby gem. 40 | 41 | -------------------------------------------------------------------------------- /action.rb: -------------------------------------------------------------------------------- 1 | require "octokit" 2 | require "json" 3 | require "marky_markdown" 4 | 5 | # Each Action has an event passed to it. 6 | event = JSON.parse(File.read(ENV['GITHUB_EVENT_PATH'])) 7 | safeword = "MARKYMARKED" 8 | 9 | # puts event 10 | puts "-------------------------------------------------" 11 | 12 | # Exit Neutral if this is not a newly "opened" issue 13 | exit(78) if event["action"] != "opened" 14 | # 15 | # Grab issue body 16 | body = event["issue"]["body"] 17 | 18 | exit(78) if body.include?(safeword) 19 | 20 | # Use GITHUB_TOKEN to interact with the GitHub API 21 | client = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN']) 22 | 23 | number = event["issue"]["number"] 24 | full_name = event["repository"]["full_name"] 25 | 26 | body = MarkyMarkdown::Transformer.transform(body) 27 | 28 | # TODO: Update marky_markdown to output var object to place in comment 29 | comment = "\r\n\r\n" 30 | 31 | body << comment 32 | 33 | # Update same issue with marked file and comment 34 | client.update_issue(full_name, number, {body: body}) 35 | 36 | puts "MarkyMarkdown::Transformer succesfully marked body" 37 | puts "-------------------------------------------------" 38 | 39 | puts "Action succesful udated issue body" 40 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Variables in Markdown' 2 | description: 'Allows variable templating in Markdown.' 3 | author: 'Brian Douglas' 4 | branding: 5 | icon: 'filter' 6 | color: 'red' 7 | runs: 8 | using: 'docker' 9 | image: 'Dockerfile' 10 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | sh -c "gem install octokit" 6 | sh -c "gem install json" 7 | 8 | sh -c "ruby /action.rb $*" 9 | --------------------------------------------------------------------------------