From 1ff69385d4d145ca670968905eadc7d18bf3c679 Mon Sep 17 00:00:00 2001 From: Tommy Byrd Date: Tue, 14 Dec 2021 11:39:34 -0500 Subject: [PATCH] bring over ci setup --- .github/workflows/docker-publish.yml | 84 ++++++++++++++++ .github/workflows/test.yml | 138 +++++++++++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 .github/workflows/docker-publish.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..05b6518 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,84 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: + - 'main' + paths-ignore: + - 'README.md' + # Publish semver tags as releases. Allow for '-alpha' + # stage releases as well. + tags: + - 'v*.*.*' + - 'v*.*.*-alpha' + pull_request: + branches: + - 'main' + paths-ignore: + - 'README.md' + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Render Action Metadata + if: ${{ github.event_name != 'pull_request' }} + run: | + ./bin/render_action_metadata "docker://ghcr.io/actions/jekyll-build-pages:${{ github.ref_name }}" > action.yml + git add action.yml + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git commit -m "Add generated action.yml 🤖" + if [[ '${{ github.ref_type }}' == 'tag' ]]; then + echo "Pushing tag ${{ github.ref_name }}" + git tag -f ${{ github.ref_name }} + git push -f origin ${{ github.ref_name }} + else + echo "Pushing branch ${{ github.ref_name }}" + git push origin ${{ github.ref_name }} + fi + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8bd014f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,138 @@ +name: 'Test' + +on: + push: + branches: + - main + paths-ignore: + - 'README.md' + pull_request: + paths-ignore: + - 'README.md' + +jobs: + test-simple: + runs-on: ubuntu-latest + env: + TEST_NAME: simple + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Render Action Metadata + run: | + ./bin/render_action_metadata Dockerfile > action.yml + + - name: Test ${{ env.TEST_NAME }} Project + uses: ./ + with: + source: ./test_projects/${{ env.TEST_NAME }} + destination: ./test_projects/${{ env.TEST_NAME }}/_site + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Save test results + uses: actions/upload-artifact@v2 + with: + name: ${{ env.TEST_NAME }} + path: ./test_projects/${{ env.TEST_NAME }} + + test-readme: + runs-on: ubuntu-latest + env: + TEST_NAME: readme + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Render Action Metadata + run: | + ./bin/render_action_metadata Dockerfile > action.yml + + - name: Test ${{ env.TEST_NAME }} Project + uses: ./ + with: + source: ./test_projects/${{ env.TEST_NAME }} + destination: ./test_projects/${{ env.TEST_NAME }}/_site + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Save test results + uses: actions/upload-artifact@v2 + with: + name: ${{ env.TEST_NAME }} + path: ./test_projects/${{ env.TEST_NAME }} + + test-mojombo: + runs-on: ubuntu-latest + env: + TEST_NAME: mojombo + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Render Action Metadata + run: | + ./bin/render_action_metadata Dockerfile > action.yml + + - name: Test ${{ env.TEST_NAME }} Project + uses: ./ + with: + source: ./test_projects/${{ env.TEST_NAME }} + destination: ./test_projects/${{ env.TEST_NAME }}/_site + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Save test results + uses: actions/upload-artifact@v2 + with: + name: ${{ env.TEST_NAME }} + path: ./test_projects/${{ env.TEST_NAME }} + + test-themes: + runs-on: ubuntu-latest + env: + TEST_NAME: themes + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Render Action Metadata + run: | + ./bin/render_action_metadata Dockerfile > action.yml + + - name: Test ${{ env.TEST_NAME }} Project + uses: ./ + with: + source: ./test_projects/${{ env.TEST_NAME }} + destination: ./test_projects/${{ env.TEST_NAME }}/_site + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Save test results + uses: actions/upload-artifact@v2 + with: + name: ${{ env.TEST_NAME }} + path: ./test_projects/${{ env.TEST_NAME }} + + test-jekyll-include-cache: + runs-on: ubuntu-latest + env: + TEST_NAME: jekyll-include-cache + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Render Action Metadata + run: | + ./bin/render_action_metadata Dockerfile > action.yml + + - name: Test ${{ env.TEST_NAME }} Project + uses: ./ + with: + source: ./test_projects/${{ env.TEST_NAME }} + destination: ./test_projects/${{ env.TEST_NAME }}/_site + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Save test results + uses: actions/upload-artifact@v2 + with: + name: ${{ env.TEST_NAME }} + path: ./test_projects/${{ env.TEST_NAME }} +