Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Setup releases (#305)
Browse files Browse the repository at this point in the history
Setup infrastructure for GitHub releases and adjust documentation and wording
  • Loading branch information
lechnerc77 authored Nov 14, 2022
1 parent d7b9a4e commit 85b41eb
Show file tree
Hide file tree
Showing 19 changed files with 182 additions and 66 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docker-dev-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and Push Docker Image (DEV)

on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-dev
DEV_BRANCH: dev

jobs:
build_and_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.DEV_BRANCH }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
#with:
# buildkitd-flags: --debug

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./config/Dockerfile
build-args: |
BTPSA_VERSION_GIT_ARG=${{ github.sha }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Build and Push Docker Image
name: Build and Push Docker Image (RELEASE)

on:
release:
types: [published]
workflow_dispatch:

env:
REGISTRY: ghcr.io
Expand All @@ -17,14 +16,16 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.release.commitish }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
#with:
# buildkitd-flags: --debug

- name: Log in to the Container registry
uses: docker/login-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
integration-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/sap-samples/btp-setup-automator:main
image: ghcr.io/sap-samples/btp-setup-automator:latest
options: --user root
env:
BTPSA_PARAM_MYEMAIL: ${{ secrets.BTPSA_PARAM_MYEMAIL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test-slim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
integration-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/sap-samples/btp-setup-automator:main
image: ghcr.io/sap-samples/btp-setup-automator:latest
options: --user root
env:
BTPSA_PARAM_MYEMAIL: ${{ secrets.BTPSA_PARAM_MYEMAIL }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-metadata-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: [btp-metadata-update]

env:
TARGET_BRANCH: main
TARGET_BRANCH: dev
METADATA_SOURCE_OWNER: SAP-samples
METADATA_SOURCE_REPO: btp-service-metadata
METADATA_VERSION: v0
Expand Down Expand Up @@ -112,4 +112,4 @@ jobs:
git config user.email "[email protected]"
git config user.name "[btpsa bot] docu generation"
git diff --quiet && git diff --staged --quiet || git commit -m "[btpsa bot] Generate parameter documentation"
git push
git push origin ${{ env.TARGET_BRANCH }}
69 changes: 53 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,28 @@ In case you are new to the containers topic, we **strongly recommended** that yo

## Download and Run

Once the pre-requisites above are all met, you can either use the pre-built Docker image for the `btp-setup-automator`, or build it yourself.
Once the pre-requisites above are all met, you can either use one of the pre-built Docker images for the `btp-setup-automator`, or build it yourself.

### Option 1: Start Docker Container via Pre-Built Image (recommended)

This is the fastest way to use the `btp-setup-automator`. Open a terminal window on your machine and run the following command to pull the Docker image from the GitHub repository and start a container based upon it:
This is the fastest way to use the `btp-setup-automator`. We offer two images for the `btp-setup-automator`:

```bash
docker container run --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:main"
```
- The **release** image: This is a stable version of the `btp-setup-automator` and corresponds to the latest release visible on the [release section](https://github.com/SAP-samples/btp-setup-automator/releases) of the repository. The corresponding code is taken from the [`main branch`](https://github.com/SAP-samples/btp-setup-automator/tree/main) of the repository.
- The **dev** image: This is an up-to-date version of the `btp-setup-automator`. It usually contains newer features and fixes but was not yet officially released. The corresponding code is taken from the [`dev branch`](https://github.com/SAP-samples/btp-setup-automator/tree/dev) of the repository.

Open a terminal window on your machine and run the following command to pull the Docker image from the GitHub repository and start a container based upon it.

- For the **release** image:

```bash
docker container run --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:latest"
```

- For the **dev** image:

```bash
docker container run --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator-dev:dev"
```

Here's a brief explanation of the options used:
Expand All @@ -77,31 +90,53 @@ You can now run the main script `btpsa` with the following command and you'll be
The tool starts to execute and the only thing you need to type in is your password for your SAP BTP account.
> 📝 Tip - If you are already using VS Code, you should execute this command instead, so that the container runs "detached" (`-d`) from your command line session:
> 📝 Tip - If you are already using VS Code, you should execute this command instead, so that the container runs "detached" (`-d`) from your command line session. Here teh command when using the release image
>
> ```bash
> docker container run --rm -it -d --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:main"
> docker container run --rm -it -d --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:latest"
> ```
You can also use the provided `run` files to pull the image from the registry and start the container via one command. To do so execute the following command (clone this repo to make the commands available to you):
- bash (macOS/Linux)
- **release** image:
```bash
./run RunReleaseFromRegistry
```
- **dev** image:
```bash
./run RunFromRegistry
```
```bash
./run RunDevFromRegistry
```
- Command Prompt (Windows):
```cmd
.\run.bat RunFromRegistry
```
- **release** image:
```cmd
.\run.bat RunReleaseFromRegistry
```
- **dev** image:
```cmd
.\run.bat RunDevFromRegistry
```
- PowerShell Core (Cross Platform):
- **release** image:
```powershell
.\run.ps1 -RunReleaseFromRegistry $True
```
```powershell
.\run.ps1 -RunFromRegistry $True
```
- **dev** image:
```powershell
.\run.ps1 -RunDevFromRegistry $True
```
### Option 2: Start Docker Container With Self-Built Image
Expand Down Expand Up @@ -208,6 +243,8 @@ Checkout [the issues section in this repo](https://github.com/SAP-samples/btp-se
Checkout the [CONTRIBUTING.md file](CONTRIBUTING.md) for more details on how to contribute to this open source project.
> 📝 Tip - If you provide a pull request make sure that the basis of your work as well as the target for your pull request is the `dev` branch of this repository.
## Code of conduct
Checkout the [CODE_OF_CONDUCT.md file](CODE_OF_CONDUCT.md) for more details on the code of conduct for this open source project.
Expand Down
22 changes: 15 additions & 7 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@ docker container rm -f "${thisname}"
docker image rm -f "${thisname}"


if [ "$1" != "RunFromRegistry" ]; then
if [ "$1" == "RunReleaseFromRegistry" ]; then

echo -e "${GREEN}Building the container image ...${NOCOLOR}"
docker image build -t ${thisname}:latest -f "config/Dockerfile" .
echo -e "${GREEN}Pulling container image RELEASE from registry ...${NOCOLOR}"
docker pull ghcr.io/sap-samples/btp-setup-automator:latest

echo -e "${GREEN}Starting the container as '${thisname}' - Access possible e.g. via VS Code${NOCOLOR}"
docker container run -e BTPSA_VERSION_GIT="$(git describe --long --tags --always)" --rm -it -d --name "${thisname}" "${thisname}"
docker container run --rm -it -d --name "${thisname}" ghcr.io/sap-samples/btp-setup-automator:latest

elif [ "$1" == "RunDevFromRegistry" ]; then

echo -e "${GREEN}Pulling container image DEV from registry ...${NOCOLOR}"
docker pull ghcr.io/sap-samples/btp-setup-automator-dev:dev

echo -e "${GREEN}Starting the container as '${thisname}' - Access possible e.g. via VS Code${NOCOLOR}"
docker container run --rm -it -d --name "${thisname}" ghcr.io/sap-samples/btp-setup-automator-dev:dev

else

echo -e "${GREEN}Pulling container image from registry ...${NOCOLOR}"
docker pull ghcr.io/sap-samples/btp-setup-automator:main
echo -e "${GREEN}Building the container image ...${NOCOLOR}"
docker image build -t ${thisname}:latest -f "config/Dockerfile" .

echo -e "${GREEN}Starting the container as '${thisname}' - Access possible e.g. via VS Code${NOCOLOR}"
docker container run --rm -it -d --name "${thisname}" ghcr.io/sap-samples/btp-setup-automator:main
docker container run -e BTPSA_VERSION_GIT="$(git describe --long --tags --always)" --rm -it -d --name "${thisname}" "${thisname}"

fi
41 changes: 24 additions & 17 deletions run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,34 @@ docker container rm -f "btp-setup-automator"
docker image rm -f "btp-setup-automator"


if not "%1" == "RunFromRegistry" (

echo %ESC%[32mBuilding the container image ...%ESC%[0m
docker image build -t btp-setup-automator:latest -f .\config\Dockerfile .

echo %ESC%[32mStarting the container as 'btp-setup-automator' - Access possible e.g. via VS Code%ESC%[0m
docker container run -e BTPSA_VERSION_GIT="$(git describe --long --tags --always)" --rm -it -d --name btp-setup-automator btp-setup-automator

) else (

echo %ESC%[32mPulling container image from registry ...%ESC%[0m
docker pull ghcr.io/sap-samples/btp-setup-automator:main

echo %ESC%[32mStarting the container as 'btp-setup-automator' - Access possible e.g. via VS Code%ESC%[0m
docker container run --rm -it -d --name btp-setup-automator ghcr.io/sap-samples/btp-setup-automator:main

)
if "%1" == "RunReleaseFromRegistry" goto release
if "%1" == "RunDevFromRegistry" goto dev

echo %ESC%[32mBuilding the container image ...%ESC%[0m
docker image build -t btp-setup-automator:latest -f .\config\Dockerfile .
echo %ESC%[32mStarting the container as 'btp-setup-automator' - Access possible e.g. via VS Code%ESC%[0m
docker container run -e BTPSA_VERSION_GIT="$(git describe --long --tags --always)" --rm -it -d --name btp-setup-automator btp-setup-automator
goto end

:release
echo %ESC%[32mPulling container image RELEASE from registry ...%ESC%[0m
docker pull ghcr.io/sap-samples/btp-setup-automator:latest
echo %ESC%[32mStarting the container as 'btp-setup-automator' - Access possible e.g. via VS Code%ESC%[0m
docker container run --rm -it -d --name btp-setup-automator ghcr.io/sap-samples/btp-setup-automator:latest
goto end

:dev
echo %ESC%[32mPulling container image DEV from registry ...%ESC%[0m
docker pull ghcr.io/sap-samples/btp-setup-automator-dev:dev
echo %ESC%[32mStarting the container as 'btp-setup-automator' - Access possible e.g. via VS Code%ESC%[0m
docker container run --rm -it -d --name btp-setup-automator ghcr.io/sap-samples/btp-setup-automator-dev:dev
goto end

:setESC
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set ESC=%%b
exit /B 0
)

:end
exit /B 0
26 changes: 18 additions & 8 deletions run.ps1
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
#!/usr/bin/pwsh
Param(
[Parameter(Mandatory=$False)]
[bool]$RunFromRegistry = $False
[bool]$RunReleaseFromRegistry = $False,
[bool]$RunDevFromRegistry = $False
)

Write-Host "Cleaning up containers and images (if existing)" -ForegroundColor green
docker container stop "btp-setup-automator"
docker container rm -f "btp-setup-automator"
docker image rm -f "btp-setup-automator"

if ( $RunFromRegistry -eq $False )
if ( $RunReleaseFromRegistry -eq $True )
{
Write-Host "Building the container image ..." -ForegroundColor green
docker image build -t btp-setup-automator:latest -f "config/Dockerfile" .
Write-Host "Pulling container image RELEASE from registry ..." -ForegroundColor green
docker pull ghcr.io/sap-samples/btp-setup-automator:latest

Write-Host "Starting the container as 'btp-setup-automator' - Access possible e.g. via VS Code" -ForegroundColor green
docker container run -e BTPSA_VERSION_GIT="$(git describe --long --tags --always)" --rm -it -d --name "btp-setup-automator" "btp-setup-automator"
docker container run --rm -it -d --name "btp-setup-automator" ghcr.io/sap-samples/btp-setup-automator:latest
}

elseif ($RunDevFromRegistry -eq $True) {
Write-Host "Pulling container image DEV from registry ..." -ForegroundColor green
docker pull ghcr.io/sap-samples/btp-setup-automator-dev:dev

Write-Host "Starting the container as 'btp-setup-automator' - Access possible e.g. via VS Code" -ForegroundColor green
docker container run --rm -it -d --name "btp-setup-automator" ghcr.io/sap-samples/btp-setup-automator-dev:dev
}

else
{
Write-Host "Pulling container image from registry ..." -ForegroundColor green
docker pull ghcr.io/sap-samples/btp-setup-automator:main
Write-Host "Building the container image ..." -ForegroundColor green
docker image build -t btp-setup-automator:latest -f "config/Dockerfile" .

Write-Host "Starting the container as 'btp-setup-automator' - Access possible e.g. via VS Code" -ForegroundColor green
docker container run --rm -it -d --name "btp-setup-automator" ghcr.io/sap-samples/btp-setup-automator:main
docker container run -e BTPSA_VERSION_GIT="$(git describe --long --tags --always)" --rm -it -d --name "btp-setup-automator" "btp-setup-automator"
}
2 changes: 1 addition & 1 deletion usecases/other/discoverycenter/3774-taskcenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Open a command line terminal on your machine.
Enter the following command into the terminal and press the `ENTER` key:

```bash
docker container run --platform linux/amd64 --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:main"
docker container run --platform linux/amd64 --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:latest"
```

You'll notice that the prompt in your terminal has changed, because you are now working inside the docker container, that you just started.
Expand Down
2 changes: 1 addition & 1 deletion usecases/other/dsag/2022-technologydays/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Open a command line terminal on your machine.
Enter the following command into the terminal and press the `ENTER` key:

```bash
docker container run --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:main"
docker container run --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:latest"
```

You'll notice that the prompt in your terminal has changed, because you are now working inside the docker container, that you just started.
Expand Down
2 changes: 1 addition & 1 deletion usecases/released/discoverycenter/3239-customui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Open a command line terminal on your machine.
Enter the following command into the terminal and press the `ENTER` key:

```bash
docker container run --platform linux/amd64 --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:main"
docker container run --platform linux/amd64 --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:latest"
```

You'll notice that the prompt in your terminal has changed, because you are now working inside the docker container, that you just started.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Open a command line terminal on your machine.
Enter the following command into the terminal and press the `ENTER` key:

```bash
docker container run --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:main"
docker container run --rm -it --name "btp-setup-automator" "ghcr.io/sap-samples/btp-setup-automator:latest"
```

You'll notice that the prompt in your terminal has changed, because you are now working inside the docker container, that you just started.
Expand Down
Loading

0 comments on commit 85b41eb

Please sign in to comment.