Update github action version #270
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: CI.build.template | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
pull_request: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
generateInputDockerFile: | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
commit_hash: ${{ steps.set-matrix.outputs.commit_hash }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18.x" | |
- name: Install dependencies | |
run: npm install | |
- name: Remove previous Dockerfile | |
run: rm *.d | |
- name: generate Dockerfiles | |
run: node make.js -r "${{ github.ref_name }}" | |
- name: Generate matrix with all Dockerfiles of the repository | |
id: set-matrix | |
run: | | |
dockerfiles=$(ls -l *.d | grep '^-' | awk -F ' ' '{print $9}' | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
echo "dockerfiles=$dockerfiles" | |
echo "::set-output name=matrix::$dockerfiles" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-dockerfiles | |
path: "*.d" | |
if-no-files-found: warn # 'error' or 'ignore' are also available, defaults to `warn` | |
build: | |
needs: generateInputDockerFile | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
outputs: | |
matrix: ${{ steps.set-jsonimage.outputs.matrix }} | |
strategy: | |
fail-fast: false | |
matrix: | |
path: ${{ fromJson(needs.generateInputDockerFile.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
# overwrite previous Dockerfiles | |
- uses: actions/download-artifact@v4 | |
with: | |
name: artifact-dockerfiles | |
- name: Current Dockerfile | |
run: | | |
echo Dockerfile ${{ matrix.path }} | |
ls -la ${{ matrix.path }} | |
cat ${{ matrix.path }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Define platforms | |
id: define-platforms | |
run: | | |
PLATFORMS=$(grep "# platforms=" ${{ matrix.path }} | awk -F "=" '{print $2 }') | |
echo "platforms=$PLATFORMS" | |
echo "platforms=$PLATFORMS" >> "$GITHUB_OUTPUT" | |
- name: Build and push ${{ matrix.path }} | |
env: | |
image: ${{ matrix.path }} | |
imagetag: ${{ github.ref_name || 'main' }} | |
uses: docker/build-push-action@v5 | |
with: | |
file: ${{ env.image }} | |
context: . | |
platforms: ${{ steps.define-platforms.outputs.platforms }} | |
build-args: | | |
TAG=${{ env.imagetag }} | |
push: true | |
tags: | | |
abcdesktopio/${{ env.image }}:${{ env.imagetag }} | |
- uses: actions/upload-artifact@v4 | |
env: | |
image: ${{ matrix.path }} | |
imagetag: ${{ github.ref_name || 'main' }} | |
with: | |
name: artifact.${{ env.image }}.${{ env.imagetag }} | |
path: ${{ env.image }} | |
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` | |
- name: Repository Dispatch | |
env: | |
image: ${{ matrix.path }} | |
imagetag: ${{ github.ref_name || 'main' }} | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.TOKEN_DISPATCH }} | |
repository: abcdesktopio/images | |
event-type: dispatch-from-oc.apps | |
client-payload: '{ "ref_name": "${{ github.ref_name }}", "image": "${{ env.image }}", "tag": "${{ env.imagetag }}"}' | |
generateDocumentation: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: remove previous Dockerfile | |
run: rm *.d | |
- uses: actions/download-artifact@v4 | |
with: | |
name: artifact-dockerfiles | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18.x" | |
- name: Install dependencies | |
run: npm install | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: generate MarkDown files | |
run: node make-docs.js --release "${{ github.head_ref }}" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-application-md-files | |
path: "*.md" | |
if-no-files-found: error # 'error' or 'ignore' are also available, defaults to `warn` | |
- name: Repository Dispatch | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.TOKEN_DISPATCH }} | |
repository: abcdesktopio/docs | |
event-type: dispatch-from-oc.apps | |
client-payload: '{ "ref_name": "${{ github.ref_name }}", "repository": "${{ github.repository }}", "run_id": "${{ github.run_id }}", "artifact": "artifact-application-md-files" }' | |
- name: commit Dockerfiles and md files | |
env: | |
CI_COMMIT_MESSAGE: Continuous Integration Build Artifacts | |
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration | |
uses: nick-fields/retry@v2 | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: | | |
git config --global pull.ff only | |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" | |
git config --global user.email "[email protected]" | |
git add *.md *.d | |
git commit -m "${{ env.CI_COMMIT_MESSAGE }}" *.md | |
git push origin ${{ github.head_ref }} |