Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve CI/CD to prevent building the Docker image twice #55

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Docker build
name: Manual CI/CD on PRs

on:
pull_request:
workflow_dispatch:
inputs:
branch_name:
description: 'The name of the branch to build from'
required: true

jobs:
build:
Expand All @@ -11,6 +15,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch_name }}
lfs: true

- name: Install Vulkan SDK
Expand All @@ -22,6 +27,19 @@ jobs:
cache: true
destination: ${{ github.workspace }}/vulkan-sdt

- name: Build Docker image
run: docker build -t lods --build-arg VULKAN_DLL_PATH=./vulkan-sdt/1.3.268.0/runtime/x64/vulkan-1.dll .

- name: Get latest commit SHA of the branch
id: get_commit_sha
run: echo "::set-output name=sha::$(git rev-parse HEAD)"

- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Build and push
id: docker_build
run: |
docker build --no-cache --build-arg COMMIT_HASH=${{ steps.get_commit_sha.outputs.sha }} --build-arg VULKAN_DLL_PATH=./vulkan-sdt/1.3.268.0/runtime/x64/vulkan-1.dll -t quay.io/decentraland/lods-generator:${{ steps.get_commit_sha.outputs.sha }} .
docker push quay.io/decentraland/lods-generator:${{ steps.get_commit_sha.outputs.sha }}
12 changes: 7 additions & 5 deletions .github/workflows/docker-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ jobs:
install_runtime: true
cache: true
destination: ${{ github.workspace }}/vulkan-sdt

- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build and push
id: docker_build

- name: Mark published image as next
run: |
docker build --no-cache --build-arg COMMIT_HASH=${{ github.sha }} --build-arg VULKAN_DLL_PATH=./vulkan-sdt/1.3.268.0/runtime/x64/vulkan-1.dll -t quay.io/decentraland/lods-generator:next -t quay.io/decentraland/lods-generator:${{ github.sha }} .
docker push quay.io/decentraland/lods-generator:next
docker push quay.io/decentraland/lods-generator:${{ github.sha }}
COMMIT_HASH=$(git rev-parse HEAD^)
docker pull quay.io/decentraland/lods-generator:${COMMIT_HASH}
docker tag quay.io/decentraland/lods-generator:${COMMIT_HASH} quay.io/decentraland/lods-generator:next
docker push quay.io/decentraland/lods-generator:next
Loading