diff options
author | Fabian Müller <fmueller@owncloud.com> | 2021-06-09 20:50:53 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-06-10 16:59:39 +0300 |
commit | abf2a25c269c888c9eab0c1415e43093d50a7f13 (patch) | |
tree | 9286792d83a1d733bb6e9b7c43453261915f358a /.github | |
parent | 395ac240ba0beac322562d320d602effaa05297c (diff) |
Move Docker commands into script
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/run-in-docker.sh | 32 | ||||
-rw-r--r-- | .github/workflows/translate.yml | 10 |
2 files changed, 37 insertions, 5 deletions
diff --git a/.github/workflows/run-in-docker.sh b/.github/workflows/run-in-docker.sh new file mode 100644 index 000000000..e70c30bcc --- /dev/null +++ b/.github/workflows/run-in-docker.sh @@ -0,0 +1,32 @@ +#! /bin/bash + +image="$1" +shift + +commands="$@" + +if [[ "$image" == "" ]] || [[ "${commands[@]}" == "" ]]; then + echo "Usage: bash $0 <image> <commands>" + exit 1 +fi + +set -exo pipefail + +extra_args=() + +if tty -s; then + extra_args+=("-t") +fi + +docker run \ + --rm \ + --user "$(id -u)" \ + -i "${extra_args[@]}" \ + -e TX_TOKEN \ + -e HOME \ + -v "$HOME:$HOME" \ + -v "$(readlink -f .)":/ws \ + --entrypoint sh \ + -w /ws \ + "$image" \ + -c "${commands[@]}" diff --git a/.github/workflows/translate.yml b/.github/workflows/translate.yml index 5d3a91d18..8aa7b8c6d 100644 --- a/.github/workflows/translate.yml +++ b/.github/workflows/translate.yml @@ -18,20 +18,20 @@ jobs: submodules: recursive - name: l10n-read - run: docker run --user "$(id -u)" --rm -i -e TX_TOKEN -v "$(readlink -f .)":/ws rabits/qt:5.12-desktop sh -c "cd /ws/translations && make l10n-read" + run: bash .github/workflows/run-in-docker.sh rabits/qt:5.12-desktop "cd translations && make l10n-read" - name: l10n-push if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - run: docker run --user "$(id -u)" --rm -i -e TX_TOKEN -v "$(readlink -f .)":/ws --entrypoint sh owncloudci/transifex:latest -c "cd /ws/translations && make l10n-push" + run: bash .github/workflows/run-in-docker.sh owncloudci/transifex:latest "cd translations && make l10n-push" - name: l10n-pull - run: docker run --user "$(id -u)" --rm -i -e TX_TOKEN -v "$(readlink -f .)":/ws --entrypoint sh owncloudci/transifex:latest -c "cd /ws/translations && make l10n-pull" + run: bash .github/workflows/run-in-docker.sh owncloudci/transifex:latest "cd translations && make l10n-pull" - name: l10n-write - run: docker run --user "$(id -u)" --rm -i -e TX_TOKEN -v "$(readlink -f .)":/ws --entrypoint sh owncloudci/transifex:latest -c "cd /ws/translations && make l10n-write" + run: bash .github/workflows/run-in-docker.sh owncloudci/transifex:latest "cd translations && make l10n-write" - name: l10n-clean - run: docker run --user "$(id -u)" --rm -i -e TX_TOKEN -v "$(readlink -f .)":/ws --entrypoint sh owncloudci/transifex:latest -c "cd /ws/translations && make l10n-clean" + run: bash .github/workflows/run-in-docker.sh owncloudci/transifex:latest "cd translations && make l10n-clean" - name: update-repo-before-commit run: | |