Skip to content

Commit

Permalink
Add CI for container delivery in suse obs
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Apr 22, 2022
1 parent b18a9da commit b5d321c
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 3 deletions.
74 changes: 73 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile --warnings-as-errors
mix deps.compile --warnings-as-errors
mix dialyzer --plt
static-code-analysis:
Expand Down Expand Up @@ -291,3 +291,75 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

obs-commit:
name: Commit the project on OBS
runs-on: ubuntu-20.04
#if: github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
#needs: [deps, static-code-analysis, test, test-e2e]
needs: [deps]
container:
image: ghcr.io/trento-project/continuous-delivery:master
env:
GITHUB_OAUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEST_FOLDER: "/tmp/osc_project"
NAME: trento-web-image
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASS: ${{ secrets.OBS_PASS }}
OBS_PROJECT: ${{ secrets.OBS_PROJECT }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup
run: |
ssl_verify=host zypper in -y wget unzip openssl
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install assets
run: cd assets && npm install

- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
env:
ImageOS: ubuntu20

- name: Get mix deps
run: mix deps.clean --all && mix deps.get

- name: Set version
run: |
VERSION=$(./hack/get_version_from_git.sh)
sed -i 's~%%VERSION%%~'"${VERSION}"'~' packaging/suse/Dockerfile
- name: Configure OSC
# OSC credentials must be configured beforehand as the HOME variables cannot be changed from /github/home
# that is used to run osc commands
run: |
/scripts/init_osc_creds.sh
mkdir -p $HOME/.config/osc
cp /root/.config/osc/oscrc $HOME/.config/osc
- name: Commit on OBS
run: |
OBS_PACKAGE=$OBS_PROJECT/$NAME
osc checkout $OBS_PACKAGE -o $DEST_FOLDER
cp -r packaging/suse/* $DEST_FOLDER
tar -zcvf $DEST_FOLDER/web.tar.gz --exclude=.git ./
cd $DEST_FOLDER
osc ar
osc commit -m "New development version of $NAME released"
14 changes: 14 additions & 0 deletions hack/get_version_from_git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
TAG=$( git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1 )

if [ -n "${TAG}" ]; then
COMMITS_SINCE_TAG=$(git rev-list "${TAG}".. --count)
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then
COMMIT_SHA=$(git show -s --format=%ct.%h HEAD)
SUFFIX="+git.dev${COMMITS_SINCE_TAG}.${COMMIT_SHA}"
fi
else
TAG="0"
fi

echo "${TAG}${SUFFIX}"
4 changes: 2 additions & 2 deletions packaging/suse/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!BuildTag: trento/trento-web:latest
#!BuildTag: trento/trento-web:1.0.0
#!BuildTag: trento/trento-web:1.0.0-build%RELEASE%
#!BuildTag: trento/trento-web:%%VERSION%%
#!BuildTag: trento/trento-web:%%VERSION%%-build%RELEASE%
#!UseOBSRepositories

FROM bci/nodejs:16 AS assets-build
Expand Down

0 comments on commit b5d321c

Please sign in to comment.