[CI] Fix docker file and action credential issue #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Push Docker Image on Tag | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| runs-on: self-hosted | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set Tag Environment | |
| run: | | |
| echo "IMAGE_TAG=torchsim-ci:${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| echo "GITHUB_SHA=$GITHUB_SHA" >> $GITHUB_ENV | |
| echo "GITHUB_SHA=$GITHUB_SHA" | |
| - name: Pull Cached Image & Set environment | |
| env: | |
| GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }} | |
| run: | | |
| docker pull ghcr.io/psal-postech/torchsim_base:latest || echo "No cache available" | |
| gem5_response_file=/tmp/releases-gem5-latest.json | |
| response=$(curl -sH "Authorization: Bearer ${GIT_ACCESS_TOKEN}" https://api.github.com/repos/PSAL-POSTECH/GEM5/releases/latest > ${gem5_response_file} ) | |
| GEM5_ASSET_ID=$(cat ${gem5_response_file} | jq ".assets[0]."id"") | |
| echo "GEM5_ASSET_ID=$GEM5_ASSET_ID" | |
| echo "GEM5_ASSET_ID=$GEM5_ASSET_ID" >> $GITHUB_ENV | |
| llvm_response_file=/tmp/releases-gem5-latest.json | |
| response=$(curl -sH "Authorization: Bearer ${GIT_ACCESS_TOKEN}" https://api.github.com/repos/PSAL-POSTECH/llvm-project/releases/latest > ${llvm_response_file} ) | |
| LLVM_ASSET_ID=$(cat ${llvm_response_file} | jq ".assets[0]."id"") | |
| echo "LLVM_ASSET_ID=$LLVM_ASSET_ID" | |
| echo "LLVM_ASSET_ID=$LLVM_ASSET_ID" >> $GITHUB_ENV | |
| mkdir -p /tmp/torchsim-ci/${GITHUB_SHA} | |
| echo "DUMP_PATH=/tmp/torchsim-ci/${GITHUB_SHA}" | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| build-args: | | |
| GEM5_ASSET_ID=${{ env.GEM5_ASSET_ID }} | |
| LLVM_ASSET_ID=${{ env.LLVM_ASSET_ID }} | |
| TORCHSIM_SHA=${{ env.GITHUB_SHA }} | |
| secrets: | | |
| GIT_ACCESS_TOKEN=${{ secrets.GIT_ACCESS_TOKEN }} | |
| tags: ghcr.io/psal-postech/${{ env.IMAGE_TAG}} |