|
| 1 | +name: Github Pages |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ 'master' ] |
| 5 | +jobs: |
| 6 | + publish: |
| 7 | + name: Publish stats, tables and guides |
| 8 | + runs-on: ubuntu-20.04 |
| 9 | + steps: |
| 10 | + - name: Install Deps |
| 11 | + uses: mstksg/get-package@master |
| 12 | + with: |
| 13 | + apt-get: cmake ninja-build libopenscap8 libxml2-utils expat xsltproc python3-jinja2 python3-yaml python3-setuptools ansible-lint python3-github bats python3-pytest python3-pytest-cov python3-pip |
| 14 | + - name: Install deps python |
| 15 | + run: pip3 install json2html |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v2 |
| 18 | + - name: Build |
| 19 | + run: cmake .. -G Ninja |
| 20 | + working-directory: ./build |
| 21 | + - name: Build page |
| 22 | + run: ninja rhel8 |
| 23 | + working-directory: ./build |
| 24 | + - name: Build page |
| 25 | + run: ninja rhel8-html-stats rhel8-html-profile-stats -j2 |
| 26 | + working-directory: ./build |
| 27 | + - name: Generate HTML pages |
| 28 | + run: |- |
| 29 | + PAGES_DIR=__pages |
| 30 | + mkdir $PAGES_DIR |
| 31 | + STATS_DIR=$PAGES_DIR/statistics |
| 32 | + mkdir $STATS_DIR |
| 33 | + touch $STATS_DIR/index.html |
| 34 | + echo "<html>" > $STATS_DIR/index.html |
| 35 | + echo "<body>" >> $STATS_DIR/index.html |
| 36 | + echo "<ul>" >> $STATS_DIR/index.html |
| 37 | + # get supported products |
| 38 | + products=$(echo -e "import ssg.constants\nprint(ssg.constants.product_directories)" | python | sed -s "s/'//g; s/,//g; s/\[//g; s/\]//g") |
| 39 | + echo "Supported products: $products" |
| 40 | + for product in $products |
| 41 | + do |
| 42 | + if [ -d build/$product ]; then |
| 43 | + mkdir -p $STATS_DIR/$product |
| 44 | + if [ -f build/$product/product-statistics/statistics.html ]; then |
| 45 | + cp -rf build/$product/product-statistics $STATS_DIR/$product/product-statistics |
| 46 | + echo "<li><a href=\"statistics/$product/product-statistics/statistics.html\">Statistics for product: ${product}</a></li>" >> $STATS_DIR/index.html |
| 47 | + fi |
| 48 | + if [ -f build/$product/profile-statistics/statistics.html ]; then |
| 49 | + cp -rf build/$product/profile-statistics $STATS_DIR/$product/profile-statistics |
| 50 | + echo "<li><a href=\"statistics/$product/profile-statistics/statistics.html\">Profile statistics for product: ${product}</a></li>" >> $STATS_DIR/index.html |
| 51 | + fi |
| 52 | + fi |
| 53 | + done |
| 54 | + echo "</ul>" >> $STATS_DIR/index.html |
| 55 | + echo "</body>" >> $STATS_DIR/index.html |
| 56 | + echo "</html>" >> $STATS_DIR/index.html |
| 57 | +
|
| 58 | +
|
| 59 | + pushd build/guides |
| 60 | + touch index.html |
| 61 | + echo "<html>" > index.html |
| 62 | + echo "<header>" >> index.html |
| 63 | + echo "<h1>Right Click to save the guide and open it locally</h1>" >> index.html |
| 64 | + echo "</header>" >> index.html |
| 65 | + echo "<body>" >> index.html |
| 66 | + echo "<ul>" >> index.html |
| 67 | + for guide in ssg-*.html |
| 68 | + do |
| 69 | + echo "<li><a href=\"${guide}\">${guide}</a></li>" >> index.html |
| 70 | + done |
| 71 | + echo "</ul>" >> index.html |
| 72 | + echo "</body>" >> index.html |
| 73 | + echo "</html>" >> index.html |
| 74 | + popd |
| 75 | +
|
| 76 | + cp -rf build/guides $PAGES_DIR |
| 77 | +
|
| 78 | +
|
| 79 | + pushd build/tables |
| 80 | + touch index.html |
| 81 | + echo "<html>" > index.html |
| 82 | + echo "<header>" >> index.html |
| 83 | + echo "<h1>Right Click to save the table and open it locally</h1>" >> index.html |
| 84 | + echo "</header>" >> index.html |
| 85 | + echo "<body>" >> index.html |
| 86 | + echo "<ul>" >> index.html |
| 87 | + for table in table-*.html |
| 88 | + do |
| 89 | + echo "<li><a href=\"${table}\"</a></li>" >> index.html |
| 90 | + done |
| 91 | + echo "</ul>" >> index.html |
| 92 | + echo "</body>" >> index.html |
| 93 | + echo "</html>" >> index.html |
| 94 | + popd |
| 95 | +
|
| 96 | + pushd $PAGES_DIR |
| 97 | + touch index.html |
| 98 | + echo "<html>" > index.html |
| 99 | + echo "<header>" >> index.html |
| 100 | + echo "<h1>Available Artifacts</h1>" >> index.html |
| 101 | + echo "</header>" >> index.html |
| 102 | + echo "<body>" >> index.html |
| 103 | + echo "<ul>" >> index.html |
| 104 | + echo "<li><a href=\"statistics/index.html\">Statistics</a></li>" >> index.html |
| 105 | + echo "<li><a href=\"guides/index.html\">Guides</a></li>" >> index.html |
| 106 | + echo "<li><a href=\"tables/index.html\">Tables</a></li>" >> index.html |
| 107 | + echo "</ul>" >> index.html |
| 108 | + echo "</body>" >> index.html |
| 109 | + echo "</html>" >> index.html |
| 110 | + popd |
| 111 | +
|
| 112 | + cp -rf build/tables $PAGES_DIR |
| 113 | +
|
| 114 | + - name: Deploy |
| 115 | + uses: JamesIves/github-pages-deploy-action@v4.2.3 |
| 116 | + with: |
| 117 | + branch: gh-pages # The branch the action should deploy to. |
| 118 | + folder: __pages # The folder the action should deploy. |
0 commit comments