ci #137
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
name: ci | |
on: | |
push: | |
branches: | |
- 'master' | |
workflow_dispatch: | |
schedule: | |
- cron: '0 12 * * 0' | |
env: | |
MAIN_NODE_VERSION: 20 | |
DOCKERHUB_USERNAME: awharn | |
DOCKERHUB_REPO: awharn/jenkins-nvm-keytar | |
GHCR_REPO: ghcr.io/awharn-docker/jenkins-nvm-keytar | |
jobs: | |
build-and-deploy-x64: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18, 20, 22] | |
steps: | |
- name: Prepare | |
run: echo "PLATFORM_PAIR=${{matrix.node}}-linux-amd64" >> $GITHUB_ENV | |
- name: Docker Meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.DOCKERHUB_REPO }} | |
${{ env.GHCR_REPO }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Dockerhub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build & Push | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
platforms: linux/amd64 | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
IMAGE_VERSION_ARG=${{ matrix.node }} | |
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true | |
- name: Export digest | |
run: | | |
mkdir -p ${{ runner.temp }}/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "${{ runner.temp }}/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: ${{ runner.temp }}/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
overwrite: true | |
build-and-deploy-arm: | |
runs-on: fastarm | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18, 20, 22] | |
steps: | |
- name: Prepare | |
run: echo "PLATFORM_PAIR=${{matrix.node}}-linux-arm64" >> $GITHUB_ENV | |
- name: Docker Meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.DOCKERHUB_REPO }} | |
${{ env.GHCR_REPO }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
id: builder | |
- name: Login to Dockerhub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
logout: false | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PAT }} | |
logout: false | |
- name: Build & Push | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
platforms: linux/arm64 | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
IMAGE_VERSION_ARG=${{ matrix.node }} | |
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true | |
builder: ${{ steps.builder.outputs.name }} | |
- name: Export digest | |
run: | | |
mkdir -p ${{ runner.temp }}/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "${{ runner.temp }}/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: ${{ runner.temp }}/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
overwrite: true | |
merge: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18, 20, 22] | |
needs: [build-and-deploy-x64, build-and-deploy-arm] | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ runner.temp }}/digests | |
pattern: digests-${{ matrix.node }}-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.DOCKERHUB_REPO }} | |
${{ env.GHCR_REPO }} | |
tags: | | |
type=raw,value=${{ matrix.node }} | |
${{ matrix.node == env.MAIN_NODE_VERSION && 'type=raw,value=latest' || '' }} | |
- name: Wait for others | |
if: matrix.node == env.MAIN_NODE_VERSION | |
run: sleep 30 | |
- name: Create manifest list and push | |
working-directory: ${{ runner.temp }}/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ steps.meta.outputs.version }} | |
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }} | |
update-downstream: | |
runs-on: ubuntu-22.04 | |
needs: merge | |
steps: | |
- name: Update Downstream | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
run: gh workflow run -R awharn-docker/jenkins-nvm-zowe-cli -r master ci.yml |