fix permission issue in docker #3
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: DEV - Build and Push to GHCR | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - AN-205-ghcr-build-update | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - dev | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| packages: write | |
| env: | |
| IMAGE_NAME: ${{ github.repository_owner }}/coordinatecore | |
| ENV_TYPE: dev | |
| jobs: | |
| build-and-push: | |
| name: Build and Push Docker Image | |
| if: ${{ github.event_name == 'push' || github.event.pull_request.merged == true }} | |
| runs-on: governance-testenv-github-self-hosted | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Cache CMake build | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| build | |
| ~/.cache | |
| key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp', '**/*.h') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}- | |
| ${{ runner.os }}-cmake- | |
| - name: Cache apt packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: /var/cache/apt/archives | |
| key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/*.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt- | |
| - name: Create new tag (semantic versioning) | |
| id: tag | |
| uses: mathieudutour/github-tag-action@v6.1 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| release_branches: dev,main | |
| default_bump: patch # can be major/minor/patch | |
| - name: Install Dependencies | |
| run: | | |
| # Wait for apt lock to be released | |
| while sudo fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do | |
| echo "Waiting for other apt processes to finish..." | |
| sleep 5 | |
| done | |
| sudo apt-get update && sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| libtool \ | |
| autotools-dev \ | |
| automake \ | |
| pkg-config \ | |
| bsdmainutils \ | |
| python3 \ | |
| libevent-dev \ | |
| libboost-dev \ | |
| libsqlite3-dev \ | |
| libminiupnpc-dev \ | |
| libnatpmp-dev \ | |
| libzmq3-dev \ | |
| systemtap-sdt-dev \ | |
| curl | |
| - name: Configure with CMake | |
| run: cmake -B build -DWITH_ZMQ=ON | |
| - name: Build with CMake | |
| run: cmake --build build | |
| - name: Verify build artifacts | |
| run: ls -la build/bin/ | |
| - name: Fix Docker socket permissions | |
| run: | | |
| sudo chmod 666 /var/run/docker.sock | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=${{ steps.tag.outputs.new_tag }} | |
| type=raw,value=latest | |
| type=ref,event=branch | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache | |
| cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache,mode=max |