Skip to content

Commit

Permalink
Only download files in pre-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jiechen0826 committed Feb 14, 2025
1 parent a04e69e commit e0623de
Showing 1 changed file with 23 additions and 43 deletions.
66 changes: 23 additions & 43 deletions .github/workflows/pre.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Create Linux Boot Files
name: Pre-CI
on:
- push
- pull_request_target
push:
pull_request_target:
# branches:
# - main # The workflow would be run based on the workflow file of the base branch to protect against malicious workflow in the PR.

env:
LCOW_ARTIFACT_PROJECT: "ContainerPlatform"
Expand All @@ -14,7 +16,7 @@ jobs:
# This job downloads the Linux boot files from the Azure Artifact feed and
# create the rootfs containing the local Linux-GCS. It needs to be run on
# the 1ES github runner pool in order to access the Azure Artifact feed.
create-linux-boot-files:
donwload-linux-boot-files:
runs-on:
- self-hosted
- 1ES.Pool=containerplat-github-runner-pool-east-us-2
Expand All @@ -26,25 +28,26 @@ jobs:
- name: Check access
if: ${{ github.event.pull_request.author_association != 'COLLABORATOR' && github.event.pull_request.author_association != 'OWNER' }}
run: |
echo "Event not triggered by a collaborator. Will not continue CI."
echo "Author association: ${{ github.event.pull_request.author_association }}"
echo "Pull Request: ${{ github.event.pull_request }}"
echo "Event not triggered by a collaborator. Will not continue CI."
exit 1
- name: Checkout hcsshim
uses: actions/checkout@v4
with:
show-progress: false
# - name: Checkout hcsshim
# uses: actions/checkout@v4
# with:
# show-progress: false

# Install Azure CLI and login to Azure
- name: Azure OIDC Login
uses: azure/login@v2
with:
auth-type: IDENTITY
client-id: "930a0428-2b45-4cf9-9afe-b81bde516504"
tenant-id: "72f988bf-86f1-41af-91ab-2d7cd011db47"
allow-no-subscriptions: true

- name: Download artifact from feed
- name: Download Linux artifact from feed
uses: azure/cli@v2
with:
azcliversion: latest
Expand All @@ -64,52 +67,29 @@ jobs:
- name: Show downloaded lcow artifacts
run: find ./downloaded_artifacts -maxdepth 3 -ls

- name: Create directory for storing linux boot files
- name: Create directory for storing linux artifacts
run: |
mkdir -p ${{ env.LINUX_BOOT_FILES_PATH }}/
mkdir -p ./temp_rootfs/
mkdir -p ./linux_artifacts/
- name: Copy Linux kernel and rootfs tar files
run: |
mv ./downloaded_artifacts/LinuxBootFiles/kernel ${{ env.LINUX_BOOT_FILES_PATH }}/
mv ./downloaded_artifacts/LinuxBootFiles/vmlinux ${{ env.LINUX_BOOT_FILES_PATH }}/
mv ./downloaded_artifacts/rootfs-*.tar.gz ./temp_rootfs/
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y make gcc binutils linux-headers-generic \
libarchive-tools btrfs-progs libseccomp-dev pkg-config cpio libkmod-dev
- name: Create rootfs containing the local Linux-GCS
run: |
chmod a+x ${{ github.workspace }}/hack/catcpio.sh
# Find the full file name for rootfs tar
ROOTFS_TAR=$(ls temp_rootfs/rootfs-*.tar.gz | head -n 1)
echo "The full file name is $ROOTFS_TAR"
make clean
sudo make KMOD=1 BASE=${{ github.workspace }}/$ROOTFS_TAR rootfs
- name: Move newly created rootfs.vhd and initrd.img
run: |
mv out/rootfs.vhd ${{ env.LINUX_BOOT_FILES_PATH }}/
mv out/initrd.img ${{ env.LINUX_BOOT_FILES_PATH }}/
mv ./downloaded_artifacts/LinuxBootFiles/kernel ./linux_artifacts/
mv ./downloaded_artifacts/LinuxBootFiles/vmlinux ./linux_artifacts/
mv ./downloaded_artifacts/rootfs-*.tar.gz ./linux_artifacts/
# This is a workaround to overcome the limitation of actions/upload-artifact@v4 used in later jobs.
# See https://github.com/actions/upload-artifact/tree/v4/?tab=readme-ov-file#permission-loss.
- name: Tar the files to preserve file permissions prior to upload
run: |
cd ${{ env.LINUX_BOOT_FILES_PATH }}
tar -cvf ../linux_boot_files.tar .
cd linux_artifacts
tar -cvf linux_artifacts.tar .
# Upload the Linux boot files so that they can be used in later jobs.
- name: Upload Linux boot files to artifact
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
with:
name: linux_artifact
path: linux_boot_files.tar
path: linux_artifact.tar
if-no-files-found: error
overwrite: true
retention-days: 1

0 comments on commit e0623de

Please sign in to comment.