Skip to content

[CI] CI refactor duplicated CI #152

[CI] CI refactor duplicated CI

[CI] CI refactor duplicated CI #152

name: Docker Base Image CI
on:
push:
branches: [ "base" ]
repository_dispatch:
types: [ build_base ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Step 1: Checkout the repository
- name: Checkout Code
uses: actions/checkout@v4
# Step 2: Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Step 2: Set environemnt
- name: Set environment
env:
GIT_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "IMAGE_TAG=torchsim-ci:${GITHUB_SHA}" >> $GITHUB_ENV
echo "GITHUB_SHA=${{github.event.pull_request.head.sha}}" >> $GITHUB_ENV
echo "GITHUB_SHA=${{github.event.pull_request.head.sha}}"
gem5_response_file=/tmp/releases-gem5-latest.json
curl -s https://api.github.com/repos/PSAL-POSTECH/GEM5/releases/latest > ${gem5_response_file}
GEM5_ASSET_ID=$(jq ".assets[0].id" ${gem5_response_file})
echo "GEM5_ASSET_ID=$GEM5_ASSET_ID"
echo "GEM5_ASSET_ID=$GEM5_ASSET_ID" >> $GITHUB_ENV
llvm_response_file=/tmp/releases-gem5-latest.json
curl -s https://api.github.com/repos/PSAL-POSTECH/llvm-project/releases/latest > ${llvm_response_file}
LLVM_ASSET_ID=$(jq ".assets[0].id" ${llvm_response_file})
echo "LLVM_ASSET_ID=$LLVM_ASSET_ID"
echo "LLVM_ASSET_ID=$LLVM_ASSET_ID" >> $GITHUB_ENV
spike_response_file=/tmp/releases-spike-latest.json
curl -s https://api.github.com/repos/PSAL-POSTECH/riscv-isa-sim/releases/latest > ${spike_response_file}
SPIKE_ASSET_ID=$(jq ".assets[0].id" ${spike_response_file})
echo "SPIKE_ASSET_ID=$SPIKE_ASSET_ID"
echo "SPIKE_ASSET_ID=$SPIKE_ASSET_ID" >> $GITHUB_ENV
# Step 3: Build and Push Docker Image
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.base
push: true
build-args: |
GEM5_ASSET_ID=${{ env.GEM5_ASSET_ID }}
LLVM_ASSET_ID=${{ env.LLVM_ASSET_ID }}
SPIKE_ASSET_ID=${{ env.SPIKE_ASSET_ID }}
tags: ghcr.io/psal-postech/torchsim_base:latest