From 373af6f3fa63d6ee8c86bbe1a645835952da2c64 Mon Sep 17 00:00:00 2001 From: Axel Seemann Date: Sun, 19 Nov 2023 11:52:24 +0100 Subject: [PATCH] Add first workflows --- .gitea/workflows/build.yml | 44 +++++++++++++++++++++++++++++++++++++ .gitea/workflows/deploy.yml | 36 ++++++++++++++++++++++++++++++ .gitignore | 2 ++ README.md | 10 +++++++-- 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitea/workflows/deploy.yml create mode 100644 .gitignore diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..b19139c --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,44 @@ +name: build +run-name: ${{ gitea.actor }} is building docker image ${{ gitea.repository }} on ${{ gitea.ref }} +on: + workflow_call: + secrets: + PERSONAL_ACCESS_TOKEN: + required: true + +env: + IMAGE_TAG: ${{ gitea.ref_name == 'master' && 'latest' || gitea.ref_name }} + IMAGE_NAME: ${{ gitea.repository }} + +jobs: + build: + runs-on: docker + steps: + - name: get registry from current GITHUB_SERVER_URL + run: echo "REGISTRY=${GITHUB_SERVER_URL//https:\/\//}" >> $GITHUB_ENV + + - name: build image reference + run: echo "IMAGE_URL=${{ env.REGISTRY }}/${GITHUB_REPOSITORY,,}:${{ env.IMAGE_TAG }}" >> $GITHUB_ENV + + - name: Check out repository code + uses: https://gitea.com/actions/checkout@v3 + + - name: login to registry + run: | + docker login -u ${{ gitea.actor }} -p ${{ secrets.PERSONAL_ACCESS_TOKEN }} ${{ env.REGISTRY }} + + - name: build image + run: | + docker build --progress plain \ + --cache-from ${{ env.IMAGE_URL }} \ + --pull \ + --no-cache \ + -t ${{ env.IMAGE_URL }} . + + - name: push image + run: | + docker push ${{ env.IMAGE_URL }} + + - name: logout from registry + run: | + docker logout ${{ env.REGISTRY }} diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..b3e2463 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,36 @@ +name: deploy +run-name: ${{ gitea.actor }} is deploying ${{ gitea.repository }} on ${{ gitea.ref }} +on: + workflow_call: + inputs: + SSH_HOST: + type: string + required: true + SSH_USER: + type: string + required: true + SSH_PORT: + type: number + required: false + default: 22 + DEPLOY_PATH: + type: string + required: true + secrets: + SSH_PASSWORD: + required: false +jobs: + build: + uses: ./.gitea/workflows/build.yml + + deploy: + runs-on: docker + needs: build + steps: + + - name: Check out repository code + uses: https://gitea.com/actions/checkout@v3 + + - name: deploy to remote host + run: | + SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${{ inputs.SSH_PORT }} ${{ inputs.SSH_USER }}@${{ inputs.SSH_HOST }}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..706fd07 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +.vscode diff --git a/README.md b/README.md index ac6ca29..584fb5e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ -# workflows +# Workflows -Containing default workflows which can be used in other repositoreis. \ No newline at end of file +Containing default workflows which can be used in other repositories. + +## Docker build and push + +## Deploy + +## Run tests