Browse Source

update workflows

liuyuqi-dellpc 2 years ago
parent
commit
02841dc7f2

+ 35 - 0
.github/workflows/test.yml

@@ -0,0 +1,35 @@
+name: Github-Action-Test
+
+on:
+  push:
+    branches: [master]
+    tags:
+      - v*
+# v1.2.1
+
+on:
+  pull_request:
+  # 新建一个PR时
+    types: [create, synchronize, update]
+    branches: [feature/**]
+on:
+  schedule:
+  # 每天凌晨 8:30 执行
+    cron: "30 8 * * *"
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v2
+
+      # 输出环境变量
+      - run: echo $CI
+      - run: echo $GITHUB_REPOSITORY
+      - run: echo $GITHUB_EVENT_NAME
+      - run: echo $GITHUB_SHA
+      - run: echo $GITHUB_REF_NAME
+      - run: echo $GITHUB_HEAD_REF
+      - name: Dump GitHub context
+        run: echo '${{ toJSON(github) }}'

+ 1 - 0
android-eclipse/.github/workflows/main.yml

@@ -20,5 +20,6 @@ jobs:
         with:
           java-version: 1.8
           distribution: 'adopt'
+    
   #     - name: Build Debug APK
   #       run:

+ 22 - 1
docker/.github/workflows/vue_deploy.yml

@@ -55,4 +55,25 @@ jobs:
           username: ${{secrets.DOCKER_HUB_NAME}}
           password: ${{secrets.DOCKER_HUB_PASSWORD}}
           repository: jianboy/vue_demo
-          tags: test
+          tags: test
+# 构建镜像,推送镜像到仓库,并创建tag,部署
+  deploy:
+    needs: [docker_image]
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - run: |
+      docker login -u ${{secrets.DOCKER_HUB_NAME}} -p ${{secrets.DOCKER_HUB_PASSWORD}}
+      docker-compose -f docker-compose.yml up -d
+
+# 登录远程服务器,拉取代码,部署
+  deploy2:
+    runs-on: ubuntu-latest
+    steps:
+      - run: |
+      ssh -p 2222 jianboy@xx.com
+      cd ~/xx/xx/xx/
+      git fetch origin master
+      git reset --hard origin/master
+      docker-compose -f docker-compose.yml up -d
+    

+ 4 - 4
dotnet/.github/workflows/main.yml

@@ -13,10 +13,10 @@ jobs:
       steps:
         - uses: actions/checkout@v2
 
-        - name: Setup .NET Core SDK
-          uses: actions/setup-dotnet@v1
-          with:
-            dotnet-version: 3.1.100
+        - name: Setup .NET Core SDK
+          uses: actions/setup-dotnet@v1
+          with:
+            dotnet-version: 3.1.100
 
         - uses: actions/cache@v2
           with:

+ 10 - 1
go/.github/workflows/main.yml

@@ -7,7 +7,16 @@ on:
     branches: [ master ]
 
 jobs:
-
+  test:
+    runs-on: [ ubuntu-latest ]
+    if: github.ref=='refs/heads/master' || github.ref=='refs/heads/main' || starts-with(github.ref, 'refs/tags/')
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-go@v1
+      - name: Test
+        run: |
+          go test -v ./...
+        
   build:
     name: Build
     strategy:

+ 0 - 0
go/README.md


+ 48 - 0
java/.github/workflows/main.yml

@@ -15,6 +15,18 @@ jobs:
       - name: Check out code
         uses: actions/checkout@v2
 
+      - name: Set up JDK 1.8
+        uses: actions/setup-java@v2
+        with:
+          version: 1.8
+          jdk: true
+
+      - name: Dump Github context
+        env:
+          GITHUB_CONTEXT: '${{ toJSON(github) }}'
+        run: |
+          echo " hello ${{ github.event.commits[0].id }}"
+
       - name: Cache local Maven repository
         uses: actions/cache@v2
         with:
@@ -32,3 +44,39 @@ jobs:
           restore-keys: |
             ${{ runner.os }}-gradle-
 
+      - name: Build with Gradle
+        run: |
+          chmod +x gradlew
+          ./gradlew build
+      
+      - name: Extract files from jar
+        run: |
+          mkdir -p build/libs
+      
+      - name: build docker image and push
+        env:
+          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
+          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
+          DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
+        run: |
+          docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} ${{ secrets.DOCKER_REGISTRY }}
+      
+      - name: set buildx
+        uses: crazy-max/ghaction-docker-buildx@v1
+        with:
+          buildx-version: latest
+
+      - name: push docker image
+        run: |
+        cd build && \
+        fullCommit="${{ github.event.commits[0].id }}" && \
+        docker buildx build \
+          --platform linux/amd64,linux/arm64,linux/arm/v7 \
+          --tag ${{ secrets.DOCKER_REGISTRY }}/{{ github.repository.owner.login }}/{{ github.repository.name }}:${{ fullCommit: 0:7 }} \
+          --progress=plain \
+          --file Dockerfile . \
+          --output "type=image,push=true"
+          --push
+
+      - name: deploy to docker
+      

+ 24 - 0
php/.dockerignore

@@ -0,0 +1,24 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/bin
+**/charts
+**/docker-compose*
+**/compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+README.md

+ 26 - 1
php/.github/workflows/main.yml

@@ -25,4 +25,29 @@ jobs:
           path: ${{ steps.composer-cache.outputs.dir }}
           key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
           restore-keys: |
-            ${{ runner.os }}-composer-
+            ${{ runner.os }}-composer-
+     
+      - name: Install dependencies
+        uses: actions/composer@v2
+        with:
+          composer-file: composer.json
+          composer-args: "install --no-dev"
+       
+      - name: Deploy
+        run: |
+          ssh -p 2222 jianboy@xx.com
+          cd ~/xx/xx/xx/
+          mv _4_5OI.git .git
+          git fetch origin master
+          git reset --hard origin/master
+          mv .git _4_5OI.git
+
+      - name: build docker images and push 
+        run: |
+        docker build -t jianboy/blog.yoqi.me:latest .
+        docker push jianboy/blog.yoqi.me:latest
+
+      - name: Deploy with Docker
+        run: |
+        ssh -p 2222 
+        docker-compose up -d

+ 0 - 0
php/Dockerfile


+ 8 - 0
php/docker-compose.debug.yml

@@ -0,0 +1,8 @@
+version: '3.4'
+
+services:
+  githubactionscreator:
+    image: githubactionscreator
+    build:
+      context: .
+      dockerfile: ./Dockerfile

+ 20 - 0
php/docker-compose.yml

@@ -0,0 +1,20 @@
+version: '3.4'
+
+services:
+  app:
+    image: githubactionscreator
+    build:
+      context: .
+      dockerfile: ./Dockerfile
+  
+  nginx:
+    image: imageName
+  
+  redis:
+    image: imageName
+  
+  mysql:
+    image: imageName
+  
+  php:
+    image: imageName