Skip to content

fix

fix #143

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
release:
types: [published]
workflow_dispatch:
repository_dispatch:
types: [start-ci, deploy-demo]
env:
ELIXIR_VERSION: 1.15.7
OTP_VERSION: 26
MIX_ENV: test
NODE_VERSION: "16"
jobs:
obs-commit-image:
name: Commit to OBS to generate container image
runs-on: ubuntu-20.04
if: github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
container:
image: ghcr.io/trento-project/continuous-delivery:main
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 }}
FOLDER: packaging/suse/container
REPOSITORY: ${{ github.repository }}
options: -u 0:0
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
- uses: actions-ecosystem/action-get-latest-tag@v1
id: latest-tag
with:
semver_only: true
initial_version: 0.0.1
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install assets
run: cd assets && npm install
- name: Get mix deps
run: mix local.hex --force && mix deps.clean --all && mix deps.get
- 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: |
mkdir -p $HOME/.config/osc
cp /home/osc/.config/osc/oscrc $HOME/.config/osc
/scripts/init_osc_creds.sh
- name: Prepare .changes file
# The .changes file is updated only in release creation. This current task should be improved
# in order to add the current rolling release notes
if: github.event_name == 'release'
run: |
CHANGES_FILE=$NAME.changes
osc checkout $OBS_PROJECT $NAME $CHANGES_FILE
mv $CHANGES_FILE $FOLDER
VERSION=${{ steps.latest-tag.outputs.tag }}
hack/gh_release_to_obs_changeset.py $REPOSITORY -a shap-staff@suse.de -t $VERSION -f $FOLDER/$CHANGES_FILE
- name: Set version
run: |
git config --global --add safe.directory /__w/web/web
VERSION=$(./hack/get_version_from_git.sh)
# "+" character is not allowed in OBS dockerfile version strings
VERSION=${VERSION//[+]/-}
sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/trento-web.spec
- name: Commit on OBS
run: |
OBS_PACKAGE=$OBS_PROJECT/$NAME
osc checkout $OBS_PACKAGE -o $DEST_FOLDER
cp -r $FOLDER/* $DEST_FOLDER
tar --transform 's,^./,/web/,' -zcvf $DEST_FOLDER/web.tar.gz --exclude=./.git ./*
cd $DEST_FOLDER
osc ar
osc commit -m "New development version of $NAME released"
obs-commit-rpm:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
container:
image: ghcr.io/trento-project/continuous-delivery:main
env:
OSC_CHECKOUT_DIR: /tmp/trento-web-package
REPOSITORY: ${{ github.repository }}
FOLDER: packaging/suse/rpm
options: -u 0:0
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install assets
run: cd assets && npm install
- name: Get mix deps
run: mix local.hex --force && mix deps.clean --all && mix deps.get
- name: configure OSC
run: |
mkdir -p $HOME/.config/osc
cp /home/osc/.config/osc/oscrc $HOME/.config/osc
/scripts/init_osc_creds.sh
- name: prepare _service file
run: |
git config --global --add safe.directory /__w/web/web
VERSION=$(./hack/get_version_from_git.sh)
sed -i 's~%%REVISION%%~'"${REVISION}"'~' $FOLDER/_service && \
sed -i 's~%%REPOSITORY%%~'"${REPOSITORY}"'~' $FOLDER/_service && \
sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/_service
- name: checkout and prepare OBS package
run: |
osc checkout $OBS_PROJECT trento-web -o $OSC_CHECKOUT_DIR
cp $FOLDER/_service $OSC_CHECKOUT_DIR
rm -v $OSC_CHECKOUT_DIR/*.tar.gz
pushd $OSC_CHECKOUT_DIR
osc service manualrun
- name: prepare trento-web.changes file
# The .changes file is updated only in release creation. This current task should be improved
# in order to add the current rolling release notes
if: github.event_name == 'release'
run: |
git config --global --add safe.directory /__w/web/web
VERSION=$(./hack/get_version_from_git.sh)
TAG=$(echo $VERSION | cut -f1 -d+)
hack/gh_release_to_obs_changeset.py $REPOSITORY -a shap-staff@suse.de -t $TAG -f $OSC_CHECKOUT_DIR/trento-web.changes
- name: commit changes into OBS
run: |
pushd $OSC_CHECKOUT_DIR
osc ar
osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}"