Skip to content

Commit

Permalink
[Action] Add composite action for duplicated works
Browse files Browse the repository at this point in the history
 - use composite action for git push.
 - use composite action for s3 upload.

Signed-off-by: Gichan Jang <[email protected]>
  • Loading branch information
gichan-jang authored and myungjoo committed Nov 12, 2024
1 parent 18eeafd commit 8ffa911
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 57 deletions.
40 changes: 40 additions & 0 deletions .github/actions/gitpush/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Push to github.io'
description: 'Update the github action result to nnstreamer.github.io'
inputs:
source:
description: 'source path of the file or directory to be copied'
required: true
dest:
description: 'destination directory in nnstreamer.github.io repository'
required: true
message:
description: 'commit message'
required: false
default: 'Update the result from nnstreamer github action.'
taos_account:
required: true
taos_account_token:
required: true

runs:
using: "composite"
steps:
- name: update the result
run: |
git clone https://${{ inputs.taos_account }}:${{ inputs.taos_account_token }}@github.com/nnstreamer/nnstreamer.github.io.git
pushd nnstreamer.github.io
mkdir -p ${{ inputs.dest }}
cp -r ${{ inputs.source }} ${{ inputs.dest }}
git diff > git_diff.txt
DIFF_SIZE=$(stat -c%s git_diff.txt)
if [[ $DIFF_SIZE -ne 0 ]]; then
git config user.email "[email protected]"
git config user.name "nnsuite"
git add *
git commit -s -m "${{ inputs.message }}"
git push origin main -f
else
echo "Nothing to commit. Skip the push operation."
fi
popd
shell: bash
34 changes: 34 additions & 0 deletions .github/actions/s3_upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'upload to release.nnstreamer.com'
inputs:
source:
description: 'source path of the file or directory to be copied'
required: true
dest:
description: 'destination directory in release.nnstreamer.com repository'
required: true
s3_id:
required: true
s3_key:
required: true
s3_option:
required: false
default: ""

runs:
using: "composite"
steps:
- name: get date
id: get-date
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
shell: bash

- name: update the result to s3
env:
AWS_ACCESS_KEY_ID: ${{ inputs.s3_id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.s3_key }}
AWS_EC2_METADATA_DISABLED: true
run: |
aws s3 cp --region ap-northeast-2 ${{ inputs.source }} s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/${{ inputs.dest }} ${{ inputs.s3_option }}
aws s3 cp --region ap-northeast-2 ${{ inputs.source }} s3://nnstreamer-release/nnstreamer/latest/${{ inputs.dest }} ${{ inputs.s3_option }}
shell: bash
33 changes: 15 additions & 18 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ jobs:
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Update github.io
run: |
git clone https://${{ secrets.TAOS_ACCOUNT }}:${{ secrets.TAOS_ACCOUNT_TOKEN }}@github.com/nnstreamer/nnstreamer.github.io.git
cp -r Documentation/NNStreamer-doc/html/* nnstreamer.github.io/
pushd nnstreamer.github.io
git config user.email "[email protected]"
git config user.name "nnsuite"
git add *
git commit -s -m "${{ steps.get-date.outputs.date }} : Update nnstreamer.github.io"
git push origin main -f
popd
uses: ./.github/actions/gitpush
with:
source: ${{ github.workspace }}/Documentation/NNStreamer-doc/html/*
dest: ./
message: "${{ steps.get-date.outputs.date }} : Update nnstreamer.github.io."
taos_account: ${{ secrets.TAOS_ACCOUNT }}
taos_account_token: ${{ secrets.TAOS_ACCOUNT_TOKEN }}

generate_doxybook:
# reference: https://github.com/nnstreamer/TAOS-CI/tree/main/ci/doxybook
Expand All @@ -60,11 +57,11 @@ jobs:
id: get-date
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Release daily build result
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
run: |
aws s3 cp --region ap-northeast-2 latex/nnstreamer-book.pdf s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/doc/nnstreamer-book.pdf
aws s3 cp --region ap-northeast-2 latex/nnstreamer-book.pdf s3://nnstreamer-release/nnstreamer/latest/doc/nnstreamer-book.pdf
- name: Release daily build result to release.nnstreamer.com
uses: ./.github/actions/s3_upload
with:
source: ${{ github.workspace }}/latex/nnstreamer-book.pdf
dest: doc/nnstreamer-book.pdf
s3_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
s3_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
64 changes: 33 additions & 31 deletions .github/workflows/update_gbs_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,22 @@ jobs:
path: ~/GBS-ROOT/local/cache
key: gbs-cache-${{ matrix.gbs_build_arch }}-${{ steps.get-date.outputs.date }}

- name: Release daily build result
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
run: |
aws s3 cp --recursive --region ap-northeast-2 ~/GBS-ROOT/local/repos/tizen/${{ matrix.gbs_build_arch }}/RPMS/ s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/RPMS/
aws s3 cp --recursive --region ap-northeast-2 ~/GBS-ROOT/local/repos/tizen/${{ matrix.gbs_build_arch }}/RPMS/ s3://nnstreamer-release/nnstreamer/latest/RPMS/
aws s3 cp --region ap-northeast-2 ~/GBS-ROOT/local/repos/tizen/${{ matrix.gbs_build_arch }}/logs/*/*/log.txt s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/logs/tizen_gbs_${{ matrix.gbs_build_arch }}_log.txt
aws s3 cp --region ap-northeast-2 ~/GBS-ROOT/local/repos/tizen/${{ matrix.gbs_build_arch }}/logs/*/*/log.txt s3://nnstreamer-release/nnstreamer/latest/logs/tizen_gbs_${{ matrix.gbs_build_arch }}_log.txt
- name: Release daily build result to release.nnstreamer.com
uses: ./.github/actions/s3_upload
with:
source: ~/GBS-ROOT/local/repos/tizen/${{ matrix.gbs_build_arch }}/RPMS/
dest: RPMS/
s3_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
s3_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
s3_option: --recursive

- name: Release daily build log to release.nnstreamer.com
uses: ./.github/actions/s3_upload
with:
source: ~/GBS-ROOT/local/repos/tizen/${{ matrix.gbs_build_arch }}/logs/*/*/log.txt
dest: logs/tizen_gbs_${{ matrix.gbs_build_arch }}_log.txt
s3_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
s3_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}

- if: matrix.gbs_build_arch == 'x86_64'
name: extract test coverage result
Expand All @@ -86,18 +92,14 @@ jobs:
python3 .github/workflows/gen_coverage_badge.py ~/testresult/usr/share/nnstreamer/unittest/result/index.html ~/testresult/usr/share/nnstreamer/unittest/result/coverage_badge.svg
- if: matrix.gbs_build_arch == 'x86_64'
name: Update github.io
run: |
git clone https://${{ secrets.TAOS_ACCOUNT }}:${{ secrets.TAOS_ACCOUNT_TOKEN }}@github.com/nnstreamer/nnstreamer.github.io.git
pushd nnstreamer.github.io
mkdir -p testresult
cp -r ~/testresult/usr/share/nnstreamer/unittest/result/* testresult
git config user.email "[email protected]"
git config user.name "nnsuite"
git add *
git commit -s -m "${{ steps.get-date.outputs.date }} : Update unit test result."
git push origin main -f
popd
name: update test coverage result to github.io
uses: ./.github/actions/gitpush
with:
source: ~/testresult/usr/share/nnstreamer/unittest/result/*
dest: testresult
message: "${{ steps.get-date.outputs.date }} : Update test coverage result."
taos_account: ${{ secrets.TAOS_ACCOUNT }}
taos_account_token: ${{ secrets.TAOS_ACCOUNT_TOKEN }}

- name: Get nntrainer
uses: actions/checkout@v4
Expand All @@ -124,12 +126,12 @@ jobs:
pip install pybadges setuptools
echo '${{ toJSON( needs.cache_gbs_build.outputs) }}' > gbs_build_result.json
python3 .github/workflows/gen_gbs_result_badge.py gbs_build_result.json ~/testresult
git clone https://${{ secrets.TAOS_ACCOUNT }}:${{ secrets.TAOS_ACCOUNT_TOKEN }}@github.com/nnstreamer/nnstreamer.github.io.git
pushd nnstreamer.github.io
cp -r ~/testresult/*.svg testresult
git config user.email "[email protected]"
git config user.name "nnsuite"
git add *
git commit -s -m "Update unit test result badge."
git push origin main -f
popd
- name: update result badge to github.io
uses: ./.github/actions/gitpush
with:
source: ~/testresult/*.svg
dest: testresult
message: "Update unit test result badge."
taos_account: ${{ secrets.TAOS_ACCOUNT }}
taos_account_token: ${{ secrets.TAOS_ACCOUNT_TOKEN }}
16 changes: 8 additions & 8 deletions .github/workflows/update_pbuilder_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ jobs:
/var/cache/pbuilder/base.tgz
key: pbuilder-cache-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/debian/control') }}-${{ steps.get-date.outputs.date }}

- name: Release daily build result
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
run: |
aws s3 cp --recursive --region ap-northeast-2 ~/daily_build/ubuntu/ s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/ubuntu/
aws s3 cp --recursive --region ap-northeast-2 ~/daily_build/ubuntu/ s3://nnstreamer-release/nnstreamer/latest/ubuntu/
- name: Release daily build result to release.nnstreamer.com
uses: ./.github/actions/s3_upload
with:
source: ~/daily_build/ubuntu/
dest: ubuntu/
s3_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
s3_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
s3_option: --recursive

0 comments on commit 8ffa911

Please sign in to comment.