From 4cb8188794a0a25926cfe5a91e18a03ad2268ee9 Mon Sep 17 00:00:00 2001 From: Dimitris Moraitis <1026101+d-mo@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:00:51 +0300 Subject: [PATCH] Add initial GHCR build workflow --- .github/workflows/docker-image.yml | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..66ccaba --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,52 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "main" ] + +jobs: + build_operator_image: + runs-on: self-hosted + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@main + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + - uses: actions/checkout@v3 + - name: Build the Docker image + run: | + if [[ $GITHUB_REF == 'refs/heads/main' ]]; then + TAG=latest + else + TAG=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}| tr / -) + fi + docker build . --file Dockerfile --tag ghcr.io/dell/remote-development-operator:$TAG + docker push ghcr.io/dell/remote-development-operator:$TAG + build_devenv_image: + runs-on: self-hosted + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@main + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + - uses: actions/checkout@v3 + - name: Build the Docker image + run: | + if [[ $GITHUB_REF == 'refs/heads/main' ]]; then + TAG=latest + else + TAG=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}| tr / -) + fi + docker build . --file Dockerfile --tag ghcr.io/dell/remote-development-operator/devenv:$TAG + docker push ghcr.io/dell/remote-development-operator/devenv:$TAG