Add first workflows
This commit is contained in:
@@ -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 }}
|
||||
@@ -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 }}"
|
||||
@@ -0,0 +1,2 @@
|
||||
.idea
|
||||
.vscode
|
||||
Reference in New Issue
Block a user