Compare commits

..
Author SHA1 Message Date
Jess Bees ead53d0c8a Update debug messages
Docker / build (push) Has been cancelled
2022-03-23 14:05:59 -04:00
Jess Bees e2b13747b8 Temporary: repoint action to use published feature branch image 2022-03-22 13:48:08 -04:00
Jess Bees d0c3f534f8 Unrelated: fix a pair of shellcheck lints 2022-03-22 13:43:22 -04:00
Jess Bees 68107d3ea8 Emit telemetry after building
This commit duplicates the telemetry logic in the actions/deploy-pages action.
This Gemfile already pulls in Faraday as a dependency of octokit; the change to
Gemfile just makes its use explicit. There aren't any changes when you compare
the resulting Gemfile.lock.
2022-03-22 11:38:34 -04:00
37 changed files with 131 additions and 192 deletions
+52 -51
View File
@@ -3,65 +3,66 @@ name: Record Expected
on:
workflow_dispatch:
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
resolve-image-tag:
record-expected-output:
runs-on: ubuntu-latest
outputs:
tag: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.regex-match.outputs.group1 }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Grep action.yaml content
id: grep-image-content
run: |
image=$(grep -E "jekyll-build-pages.*\'" action.yml)
echo "::set-output name=image::$image"
- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ steps.grep-image-content.outputs.image }}
regex: "jekyll-build-pages:(.*)'"
test-builds:
needs: resolve-image-tag
runs-on: ubuntu-latest
strategy:
matrix:
test:
- simple
- readme
- octicons
- mojombo
- themes
- jekyll-include-cache
- future-false
- future-true
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Build ${{ matrix.test }} Project
- name: Build test project 'simple'
uses: ./
with:
source: ./test_projects/${{ matrix.test }}
destination: ./test_projects/${{ matrix.test }}/_expected
source: test_projects/simple
destination: test_projects/simple/_expected
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Archive ${{ matrix.test }} Project
uses: actions/upload-artifact@v3
- name: Build test project 'readme'
uses: ./
with:
name: ${{ matrix.test }}
path: ./test_projects/${{ matrix.test }}/_expected
source: test_projects/readme
destination: test_projects/readme/_expected
build_revision: JEKYLL_BUILD_REVISION
- name: Build test project 'octicons'
uses: ./
with:
source: test_projects/octicons
destination: test_projects/octicons/_expected
build_revision: JEKYLL_BUILD_REVISION
- name: Build test project 'mojombo'
uses: ./
with:
source: test_projects/mojombo
destination: test_projects/mojombo/_expected
build_revision: JEKYLL_BUILD_REVISION
- name: Build test project 'themes'
uses: ./
with:
source: test_projects/themes
destination: test_projects/themes/_expected
build_revision: JEKYLL_BUILD_REVISION
- name: Build test project 'jekyll-include-cache'
uses: ./
with:
source: test_projects/jekyll-include-cache
destination: test_projects/jekyll-include-cache/_expected
build_revision: JEKYLL_BUILD_REVISION
- name: Build test project 'future-false'
uses: ./
with:
source: test_projects/future-false
destination: test_projects/future-false/_expected
build_revision: JEKYLL_BUILD_REVISION
- name: Build test project 'future-true'
uses: ./
with:
source: test_projects/future-true
destination: test_projects/future-true/_expected
build_revision: JEKYLL_BUILD_REVISION
+1
View File
@@ -20,6 +20,7 @@ ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8
COPY entrypoint.sh /entrypoint.sh
COPY bin/emit_telemetry /emit_telemetry
ENTRYPOINT ["/entrypoint.sh"]
+2 -1
View File
@@ -5,10 +5,11 @@ source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# Manage our dependency on the version of the github-pages gem here.
gem "github-pages", "= 227"
gem "github-pages", "= 225"
# Explicitly include this gem here.
# It is not directly included in the github-pages gem list of dependencies,
# even though it is included in the original GitHub Pages build infrastructure.
gem "jekyll-include-cache", "= 0.2.1"
gem "jekyll-octicons", "~> 14.2"
gem "faraday", "~> 1.10"
+2 -3
View File
@@ -1,6 +1,5 @@
name: 'Build Jekyll for GitHub Pages'
name: 'Pages Jekyll'
description: 'A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages'
author: 'GitHub'
inputs:
source:
description: 'Directory where the source files reside.'
@@ -28,4 +27,4 @@ inputs:
default: ${{ github.token }}
runs:
using: 'docker'
image: 'docker://ghcr.io/actions/jekyll-build-pages:v1.0.4'
image: 'docker://ghcr.io/actions/jekyll-build-pages:feature-emit-telemetry'
+43
View File
@@ -0,0 +1,43 @@
#! /usr/bin/env ruby
require "faraday"
require "faraday/retry"
require "json"
ACTION_NWO = ENV["GITHUB_ACTION_REPOSITORY"]
REPOSITORY_NWO = ENV["GITHUB_REPOSITORY"]
GITHUB_RUN_ID = ENV["GITHUB_RUN_ID"]
GITHUB_TOKEN = ENV["INPUT_TOKEN"]
TELEMETRY_URL = "https://api.github.com/repos/#{REPOSITORY_NWO}/pages/telemetry"
RETRY_COUNT = 3
RETRY_OPTIONS = {
max: RETRY_COUNT,
methods: [:post],
retry_statuses: [500, 502, 503, 504],
interval: 1,
backoff_factor: 2,
}
begin
connection = Faraday.new { |f| f.request :retry, RETRY_OPTIONS }
response = connection.post(
TELEMETRY_URL,
{ github_run_id: GITHUB_RUN_ID }.to_json,
{
Accept: 'application/vnd.github.v3+json',
Authorization: "Bearer #{GITHUB_TOKEN}",
'Content-type': 'application/json',
'User-Agent': "#{ACTION_NWO} Faraday #{Faraday::VERSION}",
},
)
if response.success?
STDERR.puts "Sending telemetry for run id #{GITHUB_RUN_ID}"
else response.success?
STDERR.puts "Failed to emit pages build telemetry to #{TELEMETRY_URL} : returned status code: #{response.status} after #{RETRY_COUNT + 1} attempts"
STDERR.puts response.body if response.body
end
rescue e
STDERR.puts "Failed to emit pages build telemetry: #{e}"
end
+8 -8
View File
@@ -1,14 +1,14 @@
#! /usr/bin/env sh
if [ "local" = "$1" ]; then
export JEKYLL_ENV=production
export PAGES_REPO_NWO=actions/jekyll-build-pages
export JEKYLL_BUILD_REVISION=JEKYLL_BUILD_REVISION
export JEKYLL_ENV=production
export PAGES_REPO_NWO=actions/jekyll-build-pages
export JEKYLL_BUILD_REVISION=JEKYLL_BUILD_REVISION
for dir in $(ls test_projects)
do
bundle exec github-pages build --verbose -s test_projects/$dir -d test_projects/$dir/_expected
done
for dir in test_projects/*
do
bundle exec github-pages build --verbose -s "$dir" -d "$dir/_expected"
done
else
act -b -s GITHUB_TOKEN -j record-expected-output
act -b -s GITHUB_TOKEN -j record-expected-output
fi
-96
View File
@@ -1,96 +0,0 @@
#!/usr/bin/env pwsh
#Requires -Version 7.2
<#
.SYNOPSIS
Trigger the workflow that records the tests expected outputs, wait for its execution to finish,
then bring back those results locally.
.DESCRIPTION
This script is meant to run locally outside of Actions. It relies on `gh` and `git`.
#>
# Get the repository's path (ps1 extension on the script is required for PSScriptRoot to be available 🤦)
$repositoryPath = Resolve-Path (Join-Path $PSScriptRoot '..')
# Get the test_project's path
$testProjectsPath = Resolve-Path (Join-Path $PSScriptRoot '../test_projects')
#
# Utilities
#
# Run a command and validate it returned a 0 exit code
function Invoke-Command {
param (
[ScriptBlock] $Command
)
& $Command
if ($LASTEXITCODE -ne 0) {
Write-Error "Command failed: $Command"
throw
}
}
# Get the current git ref name
function Get-GitRef {
$commitId = Invoke-Command { & git -C $repositoryPath rev-parse --abbrev-ref HEAD }
$commitId.Trim()
}
# Create a temp folder and return its path
function New-TemporaryFolder {
$path = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
New-Item -ItemType 'Directory' -Path $path | Out-Null
$path
}
#
# Main
#
# Init
Set-StrictMode -version 'Latest'
$ErrorActionPreference = 'Stop'
# Get git ref name
$ref = Get-GitRef
# Run the workflow
Write-Host 'Queue workflow'
$workflow = 'record.yml'
Invoke-Command { & gh workflow run $workflow --ref $ref | Out-Null }
# Wait for a few seconds for the workflow to get created
Write-Host 'Wait a few seconds...'
Start-Sleep -Seconds 5
# Lookup the run id (it is not perfect because of the APIs...)
Write-Host 'Lookup run id'
$runId = Invoke-Command { & gh run list --workflow $workflow --branch $ref --limit 1 --json databaseId --jq '.[].databaseId' }
# Wait for the workflow to finish
Write-Host "Wait for workflow $runId to complete"
Invoke-Command { & gh run watch $runId --exit-status }
# Download the artifacts in a temp folder
Write-Host 'Download artifacts'
$tempFolder = New-TemporaryFolder
Invoke-Command { & gh run download $runId --dir $tempFolder }
# Iterate over the test projects
Get-ChildItem -Path $testProjectsPath -Directory | ForEach-Object {
# Construct the artifact path and make sure a matching artifact is found
$artifactPath = Join-Path $tempFolder $_.BaseName
if (Test-Path $artifactPath -PathType 'Container') {
# Copy artifact to the expected output folder
$destinationPath = Join-Path $testProjectsPath $_.BaseName '_expected'
Copy-Item -Path (Join-Path $artifactPath '*') -Destination $destinationPath -Recurse -Force | Out-Null
}
# Ignore test project
else {
Write-Warning "Unable to find artifact for test project $($_.BaseName)"
}
}
+2
View File
@@ -35,3 +35,5 @@ fi
cd "$PAGES_GEM_HOME"
$GITHUB_PAGES build "$VERBOSE" "$FUTURE" --source "$SOURCE_DIRECTORY" --destination "$DESTINATION_DIRECTORY"
/emit_telemetry
@@ -7,7 +7,7 @@
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>The Future is Looking Bright! | jekyll-build-pages</title>
<meta name="generator" content="Jekyll v3.9.2" />
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="The Future is Looking Bright!" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Everythings coming up Milhouse." />
@@ -7,7 +7,7 @@
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>The Future is Looking Bright! | jekyll-build-pages</title>
<meta name="generator" content="Jekyll v3.9.2" />
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="The Future is Looking Bright!" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Everythings coming up Milhouse." />
@@ -7,7 +7,7 @@
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>We Live In Hell | jekyll-build-pages</title>
<meta name="generator" content="Jekyll v3.9.2" />
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="We Live In Hell" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="And its not even the cool hell that [redacted] are afraid of. 😭" />
@@ -6,12 +6,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>jekyll-build-pages | A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.</title>
<meta name="generator" content="Jekyll v3.9.2" />
<title>jekyll-build-pages</title>
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="jekyll-build-pages" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<meta property="og:description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<link rel="canonical" href="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:url" content="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:site_name" content="jekyll-build-pages" />
@@ -19,7 +17,7 @@
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="jekyll-build-pages" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"jekyll-build-pages","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
{"@context":"https://schema.org","@type":"WebSite","headline":"jekyll-build-pages","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/pages/actions/jekyll-build-pages/assets/css/style.css?v=JEKYLL_BUILD_REVISION">
+4 -6
View File
@@ -13,7 +13,6 @@ GEM
execjs
coffee-script-source (1.10.0)
colorator (1.1.0)
concurrent-ruby (1.1.10)
ethon (0.9.1)
ffi (>= 1.3.0)
execjs (2.7.0)
@@ -54,8 +53,7 @@ GEM
html-pipeline (2.4.2)
activesupport (>= 2)
nokogiri (>= 1.4)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
i18n (0.7.0)
jekyll (3.3.0)
addressable (~> 2.4)
colorator (~> 1.0)
@@ -108,7 +106,7 @@ GEM
minitest (5.9.1)
multipart-post (2.0.0)
net-dns (0.8.0)
nokogiri (1.13.6)
nokogiri (1.13.3)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.6.0)
@@ -128,10 +126,10 @@ GEM
faraday (~> 0.8, < 0.10)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
thread_safe (0.3.6)
thread_safe (0.3.5)
typhoeus (0.8.0)
ethon (>= 0.8.0)
tzinfo (1.2.10)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unicode-display_width (1.1.1)
+2 -4
View File
@@ -7,11 +7,9 @@
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Readme Test | jekyll-build-pages</title>
<meta name="generator" content="Jekyll v3.9.2" />
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="Readme Test" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<meta property="og:description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<link rel="canonical" href="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:url" content="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:site_name" content="jekyll-build-pages" />
@@ -19,7 +17,7 @@
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Readme Test" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"Readme Test","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
{"@context":"https://schema.org","@type":"WebSite","headline":"Readme Test","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/pages/actions/jekyll-build-pages/assets/css/style.css?v=JEKYLL_BUILD_REVISION">
+2 -4
View File
@@ -7,11 +7,9 @@
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Readme Test | jekyll-build-pages</title>
<meta name="generator" content="Jekyll v3.9.2" />
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="Readme Test" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<meta property="og:description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<link rel="canonical" href="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:url" content="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:site_name" content="jekyll-build-pages" />
@@ -19,7 +17,7 @@
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Readme Test" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"Readme Test","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
{"@context":"https://schema.org","@type":"WebSite","headline":"Readme Test","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/pages/actions/jekyll-build-pages/assets/css/style.css?v=JEKYLL_BUILD_REVISION">
+3 -5
View File
@@ -6,12 +6,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Jekyll Actions Demo | A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.</title>
<meta name="generator" content="Jekyll v3.9.2" />
<title>Jekyll Actions Demo</title>
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="Jekyll Actions Demo" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<meta property="og:description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<link rel="canonical" href="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:url" content="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:site_name" content="Jekyll Actions Demo" />
@@ -19,7 +17,7 @@
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Jekyll Actions Demo" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"Jekyll Actions Demo","name":"Jekyll Actions Demo","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
{"@context":"https://schema.org","@type":"WebSite","headline":"Jekyll Actions Demo","name":"Jekyll Actions Demo","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/pages/actions/jekyll-build-pages/assets/css/style.css?v=JEKYLL_BUILD_REVISION">

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

+4 -6
View File
@@ -6,12 +6,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>themes | A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.</title>
<meta name="generator" content="Jekyll v3.9.2" />
<title>themes</title>
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="themes" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<meta property="og:description" content="A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages." />
<link rel="canonical" href="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:url" content="https://github.com/pages/actions/jekyll-build-pages/" />
<meta property="og:site_name" content="themes" />
@@ -19,7 +17,7 @@
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="themes" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"themes","name":"themes","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
{"@context":"https://schema.org","@type":"WebSite","headline":"themes","name":"themes","url":"https://github.com/pages/actions/jekyll-build-pages/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/pages/actions/jekyll-build-pages/assets/css/style.css?v=JEKYLL_BUILD_REVISION">
@@ -45,7 +43,7 @@
<p>A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.</p>
<p></p>
<p class="view"><a href="https://github.com/actions/jekyll-build-pages">View the Project on GitHub <small>actions/jekyll-build-pages</small></a></p>