From 1a198a46133ba118cf23b194ced1685eaaf1cbe0 Mon Sep 17 00:00:00 2001 From: Martin Buchleitner Date: Thu, 16 Mar 2023 12:02:11 +0100 Subject: [PATCH 1/3] fix: use infralovers default container action Signed-off-by: Martin Buchleitner --- .github/workflows/ci.yml | 137 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..aca3c43 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,137 @@ +name: Infralovers Container Build + +# ref: github.com/infralovers/github/workflow-templates/container.yml + +on: + push: + branches: [ 'main' ] + pull_request: + branches: [ 'main' ] + +jobs: + prebuild: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.semrel.outputs.version }} + steps: + - uses: actions/checkout@v3 + + - name: Check pre-commit presence + id: precommit_exists + uses: andstor/file-existence-action@v1 + with: + files: ".pre-commit-config.yaml" + + - uses: actions/setup-python@v3 + if: steps.precommit_exists.outputs.files_exists == 'true' + + - uses: pre-commit/action@v3.0.0 + if: steps.precommit_exists.outputs.files_exists == 'true' + + - uses: go-semantic-release/action@v1 + if: github.event_name != 'pull_request' + id: semrel + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + prepend: true + dry: true + + build: + runs-on: ubuntu-latest + needs: [ prebuild ] + steps: + - uses: actions/checkout@v2 + + - name: Prepare tagging + id: prep + run: | + IMAGE_NAME=$(basename ${{ github.repository }}) + IMAGE_REPO=${{ github.repository_owner }} + if [[ -n "${{ secrets.IMAGE_NAME }}" ]]; then + IMAGE_NAME="${{ secrets.IMAGE_NAME }}" + fi + if [[ -n "${{ secrets.IMAGE_REPO }}" ]]; then + IMAGE_REPO="${{ secrets.IMAGE_REPO }}" + fi + QUAY_IMAGE="quay.io/$IMAGE_REPO/$IMAGE_NAME" + GHCR_IMAGE="ghcr.io/${{ github.repository }}" + VERSION="dev" + if [[ '${{ needs.prebuild.outputs.version }}' != '' ]]; then + VERSION="${{ needs.prebuild.outputs.version }}" + fi + if [ "${{ github.event_name }}" = "schedule" ]; then + VERSION="nightly" + fi + TAGS="${QUAY_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}" + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,${QUAY_IMAGE}:latest,${GHCR_IMAGE}:latest" + fi + echo "settings tag ${TAGS}" + echo "tags=${TAGS}" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: 'arm64,amd64' + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to Quay + if: needs.prebuild.outputs.version != '' + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USER }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Login to GitHub Container Registry + if: needs.prebuild.outputs.version != '' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.BOT_ACCESS_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' && needs.prebuild.outputs.version != '' }} + tags: ${{ steps.prep.outputs.tags }} + platforms: 'arm64,amd64' + + release: + needs: [ prebuild, build ] + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v2 + + - uses: go-semantic-release/action@v1 + if: needs.prebuild.outputs.version != '' + id: generate_changelog + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + prepend: true + changelog-file: CHANGELOG.md + + - name: Update changelog + uses: stefanzweifel/git-auto-commit-action@v4 + if: steps.generate_changelog.outputs.version != '' + with: + commit_message: 'chore(ci): commit changes from go-semantic-release' + file_pattern: CHANGELOG.md From 09425a4173149e6c985a0d3b5370103055c93390 Mon Sep 17 00:00:00 2001 From: Martin Buchleitner Date: Thu, 16 Mar 2023 12:18:34 +0100 Subject: [PATCH 2/3] fix: no arm64 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aca3c43..0565c3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: - platforms: 'arm64,amd64' + platforms: 'amd64' - name: Cache Docker layers uses: actions/cache@v2 @@ -111,7 +111,7 @@ jobs: file: ./Dockerfile push: ${{ github.event_name != 'pull_request' && needs.prebuild.outputs.version != '' }} tags: ${{ steps.prep.outputs.tags }} - platforms: 'arm64,amd64' + platforms: 'amd64' release: needs: [ prebuild, build ] From 7114bc3866a8c58128c13c0ce3094a4049631410 Mon Sep 17 00:00:00 2001 From: Martin Buchleitner Date: Thu, 16 Mar 2023 12:20:41 +0100 Subject: [PATCH 3/3] fix: update node version to 19 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 40f9308..960aa5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ -FROM node:10 +FROM node:19 -RUN npm install markdown-pdf markdownlint-cli -g --unsafe-perm \ No newline at end of file +RUN npm install markdown-pdf markdownlint-cli -g --unsafe-perm