Cache build-dependencies #96
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 and Push Docker Image to GHCR | |
on: | |
push: | |
branches: | |
- 'master' | |
pull_request: | |
permissions: {} | |
jobs: | |
xcp-ng-build-env-82: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write # Required to push packages to GHCR | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 | |
with: | |
driver: docker-container | |
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 | |
if: github.ref == 'refs/heads/master' | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow | |
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub | |
- uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 | |
with: | |
context: ./container | |
file: ./container/Dockerfile-8.x | |
push: ${{ github.ref == 'refs/heads/master' }} | |
tags: ghcr.io/${{ github.repository }}:8.2 | |
cache-from: type=gha,scope=${{ github.ref_name }}-82 # Cache layers to speed up builds | |
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-82 # Store layers in cache for future builds | |
build-args: | | |
XCP_NG_BRANCH=8.2 | |
platforms: | | |
linux/amd64 | |
xcp-ng-build-env-83: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write # Required to push packages to GHCR | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 | |
with: | |
driver: docker-container | |
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 | |
if: github.ref == 'refs/heads/master' | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow | |
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub | |
- run: echo "VERSION=$(cat ./src/xcp_ng_dev/files/protocol-version.txt | tr -d '\n')" >> $GITHUB_ENV | |
- uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 | |
with: | |
context: ./container | |
file: ./container/Dockerfile-8.x | |
push: ${{ github.ref == 'refs/heads/master' }} | |
tags: ghcr.io/${{ github.repository }}:8.3 | |
cache-from: type=gha,scope=${{ github.ref_name }}-83 # Cache layers to speed up builds | |
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-83 # Store layers in cache for future builds | |
platforms: | | |
linux/amd64 | |
# TODO: uncomment once we have a public xcp-ng 9.0 repository | |
# xcp-ng-build-env-90: | |
# runs-on: ubuntu-latest | |
# permissions: | |
# packages: write # Required to push packages to GHCR | |
# steps: | |
# - uses: actions/checkout@v4 | |
# with: | |
# persist-credentials: false | |
# - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 | |
# with: | |
# driver: docker-container | |
# - uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 | |
# if: github.ref == 'refs/heads/master' | |
# with: | |
# registry: ghcr.io | |
# username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow | |
# password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub | |
# - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 | |
# with: | |
# context: ./container | |
# file: ./container/Dockerfile-9.x | |
# platforms: | | |
# linux/amd64/v2 | |
# push: ${{ github.ref == 'refs/heads/master' }} | |
# tags: ghcr.io/${{ github.repository }}:9.0 | |
# cache-from: type=gha,scope=${{ github.ref_name }}-90 # Cache layers to speed up builds | |
# cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-90 # Store layers in cache for future builds |