From 07ef8462447d352768b8ed824424c63ecf6c1942 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 28 May 2022 11:40:57 -0700 Subject: [PATCH 1/5] CI: introduce a composite workflow for docker image handling Introduce a composite action that abstracts out the login and pushing of the container image. This allows us to uniformly perform the action without having to recheck conditions in between steps, which may drift apart. --- .github/actions/push-container/action.yml | 32 ++++++++++++++++++++ .github/workflows/llvm-project-epoch-one.yml | 11 +++---- .github/workflows/llvm-project-epoch-two.yml | 11 +++---- 3 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 .github/actions/push-container/action.yml diff --git a/.github/actions/push-container/action.yml b/.github/actions/push-container/action.yml new file mode 100644 index 0000000..cb0d1d7 --- /dev/null +++ b/.github/actions/push-container/action.yml @@ -0,0 +1,32 @@ +name: Push Container +description: Push a Container + +inputs: + registry: + description: Server address of Docker registry. + required: true + username: + description: Username used to login. + required: true + password: + description: Password or PAT used to login. + required: true + + name: + description: The name of the image to push. + required: true + tag: + description: The tag of the image to push. + required: true + +runs: + using: "composite" + steps: + - uses: docker/login-action@v2 + with: + registry: ${{ inputs.registry }} + username: ${{ inputs.username }} + password: ${{ inputs.password }} + + - run: | + docker push ${{ inputs.registry }}/${{ inputs.name }}:${{ inputs.tag }} diff --git a/.github/workflows/llvm-project-epoch-one.yml b/.github/workflows/llvm-project-epoch-one.yml index 871b30b..081cac0 100644 --- a/.github/workflows/llvm-project-epoch-one.yml +++ b/.github/workflows/llvm-project-epoch-one.yml @@ -27,15 +27,12 @@ jobs: - name: Test statically linked clang run: bash ci/test-clang.sh - - name: Login to ghcr.io + + - uses: ./.github/actions/push-container if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} - uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Push image to ghcr.io - if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} - run: | - docker push ghcr.io/clangbuiltlinux/llvm-project:stage2 + name: clangbuiltlinux/llvm-project + tag: stage2 diff --git a/.github/workflows/llvm-project-epoch-two.yml b/.github/workflows/llvm-project-epoch-two.yml index 59021e6..78f079e 100644 --- a/.github/workflows/llvm-project-epoch-two.yml +++ b/.github/workflows/llvm-project-epoch-two.yml @@ -27,15 +27,12 @@ jobs: - name: Test statically linked clang run: bash ci/test-clang.sh - - name: Login to ghcr.io + + - uses: ./.github/actions/push-container if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} - uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Push image to ghcr.io - if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} - run: | - docker push ghcr.io/clangbuiltlinux/llvm-project:stage2 + name: clangbuiltlinux/llvm-project + tag: stage2 From d2bf43847516729da5c4ad89d6775983b32c684c Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 8 Jun 2022 13:51:50 -0700 Subject: [PATCH 2/5] github: push-container: Add 'shell' to 'run' step This is necessary for run commands in composite actions: https://stackoverflow.com/questions/71041836/github-actions-required-property-is-missing-shell Signed-off-by: Nathan Chancellor --- .github/actions/push-container/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/push-container/action.yml b/.github/actions/push-container/action.yml index cb0d1d7..fec0fef 100644 --- a/.github/actions/push-container/action.yml +++ b/.github/actions/push-container/action.yml @@ -28,5 +28,6 @@ runs: username: ${{ inputs.username }} password: ${{ inputs.password }} - - run: | + - shell: bash + run: | docker push ${{ inputs.registry }}/${{ inputs.name }}:${{ inputs.tag }} From 606821f3297a924d549500caccbb6c7b534293ce Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 8 Jun 2022 13:46:36 -0700 Subject: [PATCH 3/5] github: push-container: Change 'name' to 'image' This is slightly more descriptive. Signed-off-by: Nathan Chancellor --- .github/actions/push-container/action.yml | 2 +- .github/workflows/llvm-project-epoch-one.yml | 2 +- .github/workflows/llvm-project-epoch-two.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/push-container/action.yml b/.github/actions/push-container/action.yml index fec0fef..e33eb82 100644 --- a/.github/actions/push-container/action.yml +++ b/.github/actions/push-container/action.yml @@ -12,7 +12,7 @@ inputs: description: Password or PAT used to login. required: true - name: + image: description: The name of the image to push. required: true tag: diff --git a/.github/workflows/llvm-project-epoch-one.yml b/.github/workflows/llvm-project-epoch-one.yml index 081cac0..5dfb679 100644 --- a/.github/workflows/llvm-project-epoch-one.yml +++ b/.github/workflows/llvm-project-epoch-one.yml @@ -34,5 +34,5 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: clangbuiltlinux/llvm-project + image: clangbuiltlinux/llvm-project tag: stage2 diff --git a/.github/workflows/llvm-project-epoch-two.yml b/.github/workflows/llvm-project-epoch-two.yml index 78f079e..803d7b4 100644 --- a/.github/workflows/llvm-project-epoch-two.yml +++ b/.github/workflows/llvm-project-epoch-two.yml @@ -34,5 +34,5 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: clangbuiltlinux/llvm-project + image: clangbuiltlinux/llvm-project tag: stage2 From 6f879ed157dcfe13ab047684121a0f68ccc81b5d Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 8 Jun 2022 13:47:53 -0700 Subject: [PATCH 4/5] github: workflows: Add 'name' field back to push image step Otherwise, the step will just show ./.github/actions/push-container which is not terribly descriptive. While we're here, use only one blank line between this step and the previous one, rather than two. Signed-off-by: Nathan Chancellor --- .github/workflows/llvm-project-epoch-one.yml | 4 ++-- .github/workflows/llvm-project-epoch-two.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/llvm-project-epoch-one.yml b/.github/workflows/llvm-project-epoch-one.yml index 5dfb679..586ea02 100644 --- a/.github/workflows/llvm-project-epoch-one.yml +++ b/.github/workflows/llvm-project-epoch-one.yml @@ -27,8 +27,8 @@ jobs: - name: Test statically linked clang run: bash ci/test-clang.sh - - - uses: ./.github/actions/push-container + - name: Push image to ghcr.io + uses: ./.github/actions/push-container if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} with: registry: ghcr.io diff --git a/.github/workflows/llvm-project-epoch-two.yml b/.github/workflows/llvm-project-epoch-two.yml index 803d7b4..0f85dba 100644 --- a/.github/workflows/llvm-project-epoch-two.yml +++ b/.github/workflows/llvm-project-epoch-two.yml @@ -27,8 +27,8 @@ jobs: - name: Test statically linked clang run: bash ci/test-clang.sh - - - uses: ./.github/actions/push-container + - name: Push image to ghcr.io + uses: ./.github/actions/push-container if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} with: registry: ghcr.io From 4ec747300ab113964580c08caca56d4a87b33bb3 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 8 Jun 2022 13:53:47 -0700 Subject: [PATCH 5/5] github: Apply 'push-container' action to epoch three workflow Signed-off-by: Nathan Chancellor --- .github/workflows/llvm-project-epoch-three.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/llvm-project-epoch-three.yml b/.github/workflows/llvm-project-epoch-three.yml index d1ba318..26bad9e 100644 --- a/.github/workflows/llvm-project-epoch-three.yml +++ b/.github/workflows/llvm-project-epoch-three.yml @@ -18,15 +18,12 @@ jobs: platforms: linux/amd64 tags: ghcr.io/clangbuiltlinux/llvm-project:stage3 - - name: Login to ghcr.io + - name: Push image to ghcr.io + uses: ./.github/actions/push-container if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} - uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Push image to ghcr.io - if: ${{ github.repository_owner == 'ClangBuiltLinux' && github.event_name != 'pull_request' && github.ref_name == 'main' }} - run: | - docker push ghcr.io/clangbuiltlinux/llvm-project:stage3 + image: clangbuiltlinux/llvm-project + tag: stage3