Skip to content

Commit

Permalink
Test Docker container action
Browse files Browse the repository at this point in the history
  • Loading branch information
baksetercx committed Apr 8, 2024
1 parent b8956f2 commit 8bb1687
Show file tree
Hide file tree
Showing 14 changed files with 639 additions and 677 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build images for Docker container actions

on:
push:
branches: [trunk]
pull_request:
branches: [trunk]

permissions:
contents: read
packages: write

jobs:
build_actions:
name: Build images for Docker container actions
runs-on: ubuntu-latest
strategy:
matrix:
action-dir: [gh-actions-docs]
env:
IMAGE_NAME: 'ghcr.io/3lvia/core-github-actions-templates/${{ matrix.action-dir }}:latest'
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: '${{ matrix.action-dir }}'
push: true
tags: '${{ env.IMAGE_NAME }}'
cache-from: 'type=registry,ref=${{ env.IMAGE_NAME }}'
cache-to: 'type=inline'
5 changes: 5 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
unittests:
name: Unit Tests
runs-on: ubuntu-latest
if: false # TODO: remove
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -31,6 +32,7 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
if: false # TODO: remove
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -40,6 +42,7 @@ jobs:
build:
name: Build and Scan
runs-on: ubuntu-latest
if: false # TODO: remove
environment: build
steps:
- name: Checkout repository
Expand All @@ -56,6 +59,7 @@ jobs:
name: Deploy AKS
needs: [build, analyze]
runs-on: ubuntu-latest
if: false # TODO: remove
environment: dev
steps:
- name: Checkout repository
Expand All @@ -73,6 +77,7 @@ jobs:
name: Deploy GKE
needs: [build, analyze]
runs-on: ubuntu-latest
if: false # TODO: remove
environment: dev
steps:
- name: Checkout repository
Expand Down
53 changes: 35 additions & 18 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,38 @@ name: Generate action documentation
on:
push:
branches: [trunk]
pull_request: # TODO: remove
branches: [trunk]

jobs:
generate_docs:
name: Generate action documentation
runs-on: ubuntu-latest
env:
ACTION_DIRS: 'build,deploy,trivy-iac-scan,terraform-format'
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=$(cat README.md)" >> $GITHUB_OUTPUT

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

- 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 }}" > README.md

- name: Format README
run: yarn prettier -w --single-quote README.md

- name: Debug, remove this # TODO: remove
run: cat README.md

- name: Commit changes
if: false # TODO: remove
run: |
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

0 comments on commit 8bb1687

Please sign in to comment.