mirror of
https://github.com/apple/container.git
synced 2026-09-10 01:35:41 +00:00
fix: correct release condition in GitHub Actions and globalize enviro… (#127)
# Refactor GitHub Actions Workflow: Containerization Build ## 🛠 Summary This PR introduces several important improvements and cleanups to the build-containerization-template GitHub Actions workflow for better maintainability, correctness, and readability. ### 🔧 Changes Made #### 1. ✅ Fix invalid conditional syntax - **!= is not supported in expressions** with **if**: in GitHub Actions. - Only logical operators like !, &&, || are valid. #### 2. ✅ Globalized environment variables - Moved CURRENT_SDK and DEVELOPER_DIR to the job-level env: block to: - Avoid redundancy across steps - Make the workflow more maintainable ### 3. ✅ Replaced `secrets.GITHUB_TOKEN` with `github.token` - Prefer github.token for GitHub-provided auth token to improve clarity and scoping. @katiewasnothere
This commit is contained in:
@@ -21,78 +21,81 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
env:
|
||||
CURRENT_SDK: y
|
||||
DEVELOPER_DIR: "/Applications/Xcode_26.b1.app/Contents/Developer"
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Activate Swiftly
|
||||
run: |
|
||||
source /opt/swiftly/env.sh
|
||||
cat /opt/swiftly/env.sh
|
||||
|
||||
- name: Check formatting
|
||||
run: |
|
||||
./scripts/install-hawkeye.sh
|
||||
make fmt
|
||||
git diff
|
||||
if ! git diff --quiet ; then echo the following files require formatting or license headers: ; git diff --name-only ; false ; fi
|
||||
env:
|
||||
DEVELOPER_DIR: "/Applications/Xcode_26.b1.app/Contents/Developer"
|
||||
|
||||
- name: Check protobufs
|
||||
run: |
|
||||
make protos
|
||||
if ! git diff --quiet ; then echo the following files require formatting or license headers: ; git diff --name-only ; false ; fi
|
||||
env:
|
||||
DEVELOPER_DIR: "/Applications/Xcode_26.b1.app/Contents/Developer"
|
||||
CURRENT_SDK: y
|
||||
|
||||
- name: Make containerization and docs
|
||||
run: |
|
||||
make clean containerization docs
|
||||
tar cfz _site.tgz _site
|
||||
env:
|
||||
DEVELOPER_DIR: "/Applications/Xcode_26.b1.app/Contents/Developer"
|
||||
CURRENT_SDK: y
|
||||
|
||||
- name: Make vminitd image
|
||||
run: |
|
||||
source /opt/swiftly/env.sh
|
||||
make -C vminitd swift linux-sdk
|
||||
make init
|
||||
env:
|
||||
CURRENT_SDK: y
|
||||
|
||||
- name: Test containerization
|
||||
run: |
|
||||
make fetch-default-kernel
|
||||
make test integration
|
||||
env:
|
||||
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REGISTRY_TOKEN: ${{ github.token }}
|
||||
REGISTRY_USERNAME: ${{ github.actor }}
|
||||
DEVELOPER_DIR: "/Applications/Xcode_26.b1.app/Contents/Developer"
|
||||
CURRENT_SDK: y
|
||||
|
||||
- name: Push vminitd image
|
||||
if: ${{ inputs.release }}
|
||||
run: |
|
||||
bin/cctl images tag vminit:latest ghcr.io/apple/containerization/vminit:${{ inputs.version }}
|
||||
bin/cctl images push ghcr.io/apple/containerization/vminit:${{ inputs.version }}
|
||||
env:
|
||||
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REGISTRY_TOKEN: ${{ github.token }}
|
||||
REGISTRY_USERNAME: ${{ github.actor }}
|
||||
REGISTRY_HOST: ghcr.io
|
||||
|
||||
- name: Create image tar
|
||||
if: ${{ inputs.release }} != true
|
||||
if: ${{ !inputs.release }}
|
||||
run: |
|
||||
bin/cctl images save vminit:latest -o vminit.tar
|
||||
|
||||
- name: Save vminit artifact
|
||||
if: ${{ inputs.release }} != true
|
||||
if: ${{ !inputs.release }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: vminit
|
||||
path: vminit.tar
|
||||
|
||||
- name: Save documentation artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: api-docs
|
||||
path: "./_site.tgz"
|
||||
retention-days: 14
|
||||
|
||||
uploadPages:
|
||||
# Separate upload step required because upload-pages-artifact needs
|
||||
# gtar which is not on the macOS runner.
|
||||
@@ -104,13 +107,16 @@ jobs:
|
||||
steps:
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Download a single artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: api-docs
|
||||
|
||||
- name: Add API docs to documentation
|
||||
run: |
|
||||
tar xfz _site.tgz
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user