Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Docker container action #45

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
prettier_check:
name: 'Prettier check'
runs-on: ubuntu-latest
if: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -22,7 +21,7 @@ jobs:
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
key: "${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}"

- name: Install dependencies
run: yarn install --frozen-lockfile
Expand Down
84 changes: 66 additions & 18 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,71 @@ on:
branches: [trunk]

jobs:
build_docs_image:
name: Build image for gh-actions-docs
runs-on: ubuntu-latest
env:
IMAGE_NAME: 'ghcr.io/3lvia/core-github-actions-templates/gh-actions-docs:latest'
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build image
uses: docker/build-push-action@v5
with:
context: 'gh-actions-docs'
push: true
tags: '${{ env.IMAGE_NAME }}'
cache-from: 'type=registry,ref=${{ env.IMAGE_NAME }}'
cache-to: 'type=inline'

generate_docs:
name: Generate action documentation
runs-on: ubuntu-latest
env:
ACTION_DIRS: 'build,deploy,trivy-iac-scan,terraform-format'
needs: [build_docs_image]
outputs:
readme: ${{ steps.set-output.outputs.readme }}
container:
image: ghcr.io/3lvia/core-github-actions-templates/gh-actions-docs:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Generate action documentation
run: gh-actions-docs
env:
IGNORE_FILES: 'my-new-action/action.yml'
IGNORE_HEADERS: '# core-github-actions-templates,## Table of Contents'

- name: Set output
id: set-output
run: |
{
echo 'readme<<EOF'
cat README.md | base64
echo EOF
} >> "$GITHUB_OUTPUT"

commit_docs:
name: Commit action documentation
runs-on: ubuntu-latest
needs: [generate_docs]
permissions:
contents: write
steps:
Expand All @@ -25,24 +85,13 @@ jobs:
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
key: "${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Generate action documentation
run: |
for ACTION_FILE in $(echo "$ACTION_DIRS" | tr ',' '\n'); do
yarn gen-docs "$ACTION_FILE/action.yml"
done

- name: Generate table of contents using gh-md-toc
run: |
wget "https://raw.githubusercontent.com/ekalinin/github-markdown-toc/$GH_MD_TOC_VERSION/gh-md-toc"
chmod +x gh-md-toc
./gh-md-toc --insert --no-backup --skip-header README.md
env:
GH_MD_TOC_VERSION: 0.10.0
- name: Get README from output
run: echo '${{ needs.generate_docs.outputs.readme }}' | base64 -d > README.md

- name: Format README
run: yarn prettier -w --single-quote README.md
Expand All @@ -52,5 +101,4 @@ jobs:
git config user.name github-actions
git config user.email [email protected]
git add README.md
git commit -m "Update action documentation"
git push
git commit -m
Loading
Loading