aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/push-containers.yml
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2023-06-19 13:55:32 +0200
committerChristian Marangi <ansuelsmth@gmail.com>2023-10-24 17:12:52 +0200
commit76a9b0e02a614ec15f4dc771df32de90ab30d779 (patch)
tree3a739f1a09f08ce28b08870a1d819422c23fbc86 /.github/workflows/push-containers.yml
parent3826ebbd181770d43a2a057611707d96ec90b550 (diff)
downloadupstream-76a9b0e02a614ec15f4dc771df32de90ab30d779.tar.gz
upstream-76a9b0e02a614ec15f4dc771df32de90ab30d779.tar.bz2
upstream-76a9b0e02a614ec15f4dc771df32de90ab30d779.zip
CI: migrate each workflow to use reusable workflow from dedicated repo
Migrate each workflow to use reusable workflow from dedicated repo to skip pushing CI related commits to openwrt and better track versioning of CI workflow. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> (cherry picked from commit 38cc09165fd11caa9599d960280bd91dbaba7a62)
Diffstat (limited to '.github/workflows/push-containers.yml')
-rw-r--r--.github/workflows/push-containers.yml199
1 files changed, 3 insertions, 196 deletions
diff --git a/.github/workflows/push-containers.yml b/.github/workflows/push-containers.yml
index 04a9b8d8e9..74f534d57a 100644
--- a/.github/workflows/push-containers.yml
+++ b/.github/workflows/push-containers.yml
@@ -6,13 +6,8 @@ on:
- 'include/version.mk'
- 'include/cmake.mk'
- 'tools/**'
- - '.github/workflows/build-tools.yml'
- '.github/workflows/push-containers.yml'
- - '.github/workflows/Dockerfile.tools'
- 'toolchain/**'
- - '.github/workflows/build.yml'
- - '.github/workflows/toolchain.yml'
- - '.github/workflows/Dockerfile.toolchain'
branches-ignore:
- master
@@ -24,198 +19,10 @@ concurrency:
cancel-in-progress: true
jobs:
- determine-container-info:
- name: Determine needed info to push containers
- if: ${{ github.repository_owner == 'openwrt' }}
- runs-on: ubuntu-latest
- outputs:
- owner-lc: ${{ steps.generate-owner-lc.outputs.owner-lc }}
- container-tag: ${{ steps.determine-container-tag.outputs.container-tag }}
-
- steps:
- - name: Set lower case owner name
- id: generate-owner-lc
- env:
- OWNER: ${{ github.repository_owner }}
- run: |
- echo "owner-lc=${OWNER,,}" >> "$GITHUB_OUTPUT"
-
- # Per branch tools container tag
- # By default stick to latest
- # For official test targetting openwrt stable branch
- # Get the branch or parse the tag and push dedicated tools containers
- # Any branch that will match this pattern openwrt-[0-9][0-9].[0-9][0-9]
- # will refresh the tools container with the matching tag.
- # (example branch openwrt-22.03 -> tools:openwrt-22.03)
- # (example branch openwrt-22.03-test -> tools:openwrt-22.03)
- - name: Determine tools container tag
- id: determine-container-tag
- run: |
- CONTAINER_TAG=latest
-
- if [ ${{ github.ref_type }} == "branch" ]; then
- if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
- CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\).*/\1/')"
- fi
- elif [ ${{ github.ref_type }} == "tag" ]; then
- if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
- CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
- fi
- fi
-
- echo "Container tag to push for tools and toolchain is $CONTAINER_TAG"
- echo "container-tag=$CONTAINER_TAG" >> "$GITHUB_OUTPUT"
-
- build-linux-buildbot:
- name: Build tools with buildbot container
- if: ${{ github.repository_owner == 'openwrt' }}
- uses: ./.github/workflows/build-tools.yml
- with:
- generate_prebuilt_artifacts: true
-
- push-tools-container:
- needs: [ determine-container-info, build-linux-buildbot ]
- if: ${{ github.repository_owner == 'openwrt' }}
- name: Push prebuilt tools container
- runs-on: ubuntu-latest
-
+ build-push-containers:
+ name: Build and Push all prebuilt containers
permissions:
contents: read
packages: write
-
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- with:
- path: 'openwrt'
-
- - name: Download prebuilt tools from build job
- uses: actions/download-artifact@v3
- with:
- name: linux-buildbot-prebuilt-tools
- path: openwrt
-
- - name: Extract prebuild tools
- working-directory: openwrt
- run: tar -xf tools.tar
-
- - name: Login to GitHub Container Registry
- uses: docker/login-action@v2
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Build and push
- uses: docker/build-push-action@v3
- with:
- context: openwrt
- push: true
- tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/tools:${{ needs.determine-container-info.outputs.container-tag }}
- file: openwrt/.github/workflows/Dockerfile.tools
-
- determine-targets:
- name: Set targets
- if: ${{ github.repository_owner == 'openwrt' }}
- runs-on: ubuntu-latest
- outputs:
- target: ${{ steps.find_targets.outputs.target }}
-
- steps:
- - name: Checkout
- uses: actions/checkout@v3
-
- - name: Set targets
- id: find_targets
- run: |
- export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
- | awk '{ print $1 }')"
-
- JSON='['
- FIRST=1
- for TARGET in $TARGETS; do
- TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
- [[ $FIRST -ne 1 ]] && JSON="$JSON"','
- JSON="$JSON""$TUPLE"
- FIRST=0
- done
- JSON="$JSON"']'
-
- echo -e "\n---- targets ----\n"
- echo "$JSON"
- echo -e "\n---- targets ----\n"
-
- echo "target=$JSON" >> $GITHUB_OUTPUT
-
- build:
- name: Build Target Toolchain
- if: ${{ github.repository_owner == 'openwrt' }}
- needs: [ determine-targets, push-tools-container ]
- permissions:
- contents: read
- packages: read
actions: write
- strategy:
- fail-fast: False
- matrix:
- include: ${{fromJson(needs.determine-targets.outputs.target)}}
- uses: ./.github/workflows/build.yml
- with:
- target: ${{ matrix.target }}
- subtarget: ${{ matrix.subtarget }}
- build_toolchain: true
- build_external_toolchain: true
- upload_external_toolchain: true
-
- push-toolchain-container:
- name: Push Target Toolchain container
- if: ${{ github.repository_owner == 'openwrt' }}
- needs: [ determine-container-info, determine-targets, build ]
- runs-on: ubuntu-latest
-
- strategy:
- fail-fast: False
- matrix:
- include: ${{fromJson(needs.determine-targets.outputs.target)}}
-
- permissions:
- contents: read
- packages: write
-
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- with:
- path: 'openwrt'
-
- - name: Download external toolchain from build job
- uses: actions/download-artifact@v3
- with:
- name: ${{ matrix.target }}-${{ matrix.subtarget }}-external-toolchain
- path: openwrt
-
- - name: Find external toolchain name
- id: get-toolchain-name
- working-directory: openwrt
- run: |
- TOOLCHAIN_NAME=$(ls | grep toolchain-${{ matrix.target }}-${{ matrix.subtarget }})
- echo "toolchain-name=$TOOLCHAIN_NAME" >> $GITHUB_OUTPUT
-
- - name: Login to GitHub Container Registry
- uses: docker/login-action@v2
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Build and push
- uses: docker/build-push-action@v3
- with:
- context: openwrt
- push: true
- tags: ghcr.io/${{ needs.determine-container-info.outputs.owner-lc }}/toolchain:${{ matrix.target }}-${{ matrix.subtarget }}-${{ needs.determine-container-info.outputs.container-tag }}
- file: openwrt/.github/workflows/Dockerfile.toolchain
- build-args: |
- OWNER_LC=${{ needs.determine-container-info.outputs.owner-lc }}
- CONTAINER_TAG=${{ needs.determine-container-info.outputs.container-tag }}
- TOOLCHAIN_NAME=${{ steps.get-toolchain-name.outputs.toolchain-name }}
+ uses: openwrt/actions-shared-workflows/.github/workflows/push-containers.yml@main