|
9 | 9 | default: 'patch' |
10 | 10 | type: choice |
11 | 11 | options: |
12 | | - - 'major' |
13 | | - - 'minor' |
14 | | - - 'patch' |
| 12 | + - 'major' |
| 13 | + - 'minor' |
| 14 | + - 'patch' |
15 | 15 | build_docker_image: |
16 | 16 | description: "Construire l'image docker ?" |
17 | 17 | required: true |
|
24 | 24 | type: boolean |
25 | 25 |
|
26 | 26 | jobs: |
27 | | - build-service: |
| 27 | + pre-build: |
28 | 28 | runs-on: ubuntu-latest |
29 | | - permissions: |
30 | | - contents: write |
31 | | - packages: write |
32 | | - actions: write |
33 | | - pull-requests: write |
34 | | - checks: write |
35 | | - |
36 | 29 | steps: |
37 | | - - name: Build docker |
38 | | - uses: Libertech-FR/lt-actions/release@main |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v2 |
39 | 32 | with: |
40 | | - version_increment: ${{ github.event.inputs.version_increment }} |
41 | | - build_docker_image: ${{ github.event.inputs.build_docker_image }} |
42 | | - latest: ${{ github.event.inputs.latest }} |
43 | 33 | repository: ${{ github.repository }} |
44 | | - username: ${{ github.actor }} |
45 | | - password: ${{ secrets.GITHUB_TOKEN }} |
46 | | - github_token: ${{ secrets.ACTION_TOKEN }} |
47 | | - # Optional parameters, thoses are default values : |
| 34 | + |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@v2 |
| 37 | + |
| 38 | + - name: Set up Git |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + git config user.email "github@action.com" |
| 42 | + git config user.name "Github Action" |
| 43 | + echo ${{ secrets.GITHUB_TOKEN }} > token.txt |
| 44 | + git config credential.helper "store --file=token.txt" |
| 45 | +
|
| 46 | + - name: Update version |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + echo NEW_VERSION=$(yarn version --${{ inputs.version_increment }} --json | jq -r '.data | select(contains("New version")) | split(":")[1] | gsub(" ";"")') >> $GITHUB_ENV |
| 50 | + env: |
| 51 | + REF: ${{ github.ref }} |
| 52 | + |
| 53 | + - name: Push to protected branch |
| 54 | + uses: CasperWA/push-protected@v2 |
| 55 | + with: |
| 56 | + token: ${{ secrets.ACTION_TOKEN }} |
| 57 | + branch: main |
| 58 | + unprotect_reviews: true |
| 59 | + tags: true |
| 60 | + |
| 61 | + - name: Publish release |
| 62 | + uses: ncipollo/release-action@v1 |
| 63 | + with: |
| 64 | + name: Release ${{ env.NEW_VERSION }} |
| 65 | + commit: ${{ env.REF }} |
| 66 | + draft: false |
| 67 | + prerelease: false |
| 68 | + generateReleaseNotes: true |
| 69 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + makeLatest: ${{ inputs.latest }} |
| 71 | + tag: ${{ env.NEW_VERSION }} |
| 72 | + |
| 73 | + - name: Get repo name |
| 74 | + shell: bash |
| 75 | + id: get_repo_name |
| 76 | + run: | |
| 77 | + echo "REPO_NAME=$(basename "${{ github.repository }}")" >> $GITHUB_ENV |
| 78 | +
|
| 79 | + - name: Get repo full name |
| 80 | + shell: bash |
| 81 | + id: get_repo_full_name |
| 82 | + run: | |
| 83 | + FULL_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') |
| 84 | + echo "REPO_FULL_NAME=$FULL_NAME" >> $GITHUB_ENV |
| 85 | +
|
| 86 | + - name: Get current date and time |
| 87 | + shell: bash |
| 88 | + id: get_current_date_time |
| 89 | + run: | |
| 90 | + echo "CURRENT_DATE_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV |
| 91 | +
|
| 92 | + build-service: |
| 93 | + runs-on: ubuntu-latest |
| 94 | + needs: pre-build |
| 95 | + if: ${{ inputs.build_docker_image == 'true' }} |
| 96 | + steps: |
| 97 | + - name: Define service tags |
| 98 | + shell: bash |
| 99 | + id: define_tags |
| 100 | + run: | |
| 101 | + if [ "${{ inputs.latest }}" = "true" ]; then |
| 102 | + echo "SERVICE_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/service:${{ env.NEW_VERSION }},ghcr.io/${{ env.REPO_FULL_NAME }}/service:latest" >> $GITHUB_ENV |
| 103 | + else |
| 104 | + echo "SERVICE_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/service:${{ env.NEW_VERSION }}" >> $GITHUB_ENV |
| 105 | + fi |
| 106 | + env: |
| 107 | + NEW_VERSION: ${{ env.NEW_VERSION }} |
| 108 | + REPO_NAME: ${{ env.REPO_NAME }} |
| 109 | + REPO_FULL_NAME: ${{ env.REPO_FULL_NAME }} |
| 110 | + |
| 111 | + - name: Log in to the Container registry |
| 112 | + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 |
| 113 | + with: |
48 | 114 | registry: 'ghcr.io' |
49 | | - context: ./service/ |
50 | | - is_branch_protected: true |
| 115 | + username: ${{ github.actor }} |
| 116 | + password: ${{ secrets.ACTION_TOKEN }} |
| 117 | + env: |
| 118 | + REGISTRY: 'ghcr.io' |
| 119 | + |
| 120 | + - name: Build and push Docker image |
| 121 | + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc |
| 122 | + with: |
| 123 | + context: '.' |
| 124 | + file: './service/Dockerfile' |
| 125 | + push: true |
| 126 | + tags: ${{ env.SERVICE_TAGS }} |
| 127 | + env: |
| 128 | + TAGS: ${{ env.SERVICE_TAGS }} |
51 | 129 |
|
52 | 130 | build-app: |
53 | 131 | runs-on: ubuntu-latest |
54 | | - permissions: |
55 | | - contents: write |
56 | | - packages: write |
57 | | - |
| 132 | + needs: pre-build |
| 133 | + if: ${{ inputs.build_docker_image == 'true' }} |
58 | 134 | steps: |
59 | | - - name: Build docker |
60 | | - uses: Libertech-FR/lt-actions/release@main |
| 135 | + - name: Define app tags |
| 136 | + shell: bash |
| 137 | + id: define_tags |
| 138 | + run: | |
| 139 | + if [ "${{ inputs.latest }}" = "true" ]; then |
| 140 | + echo "APP_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/app:${{ env.NEW_VERSION }},ghcr.io/${{ env.REPO_FULL_NAME }}/app:latest" >> $GITHUB_ENV |
| 141 | + else |
| 142 | + echo "APP_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/app:${{ env.NEW_VERSION }}" >> $GITHUB_ENV |
| 143 | + fi |
| 144 | + env: |
| 145 | + NEW_VERSION: ${{ env.NEW_VERSION }} |
| 146 | + REPO_NAME: ${{ env.REPO_NAME }} |
| 147 | + REPO_FULL_NAME: ${{ env.REPO_FULL_NAME }} |
| 148 | + |
| 149 | + - name: Log in to the Container registry |
| 150 | + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 |
61 | 151 | with: |
62 | | - version_increment: ${{ github.event.inputs.version_increment }} |
63 | | - build_docker_image: ${{ github.event.inputs.build_docker_image }} |
64 | | - latest: ${{ github.event.inputs.latest }} |
65 | | - repository: ${{ github.repository }} |
66 | | - username: ${{ github.actor }} |
67 | | - password: ${{ secrets.GITHUB_TOKEN }} |
68 | | - github_token: ${{ secrets.ACTION_TOKEN }} |
69 | | - # Optional parameters, thoses are default values : |
70 | 152 | registry: 'ghcr.io' |
71 | | - context: ./app/ |
72 | | - is_branch_protected: true |
| 153 | + username: ${{ github.actor }} |
| 154 | + password: ${{ secrets.ACTION_TOKEN }} |
| 155 | + env: |
| 156 | + REGISTRY: 'ghcr.io' |
| 157 | + |
| 158 | + - name: Build and push Docker image |
| 159 | + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc |
| 160 | + with: |
| 161 | + context: '.' |
| 162 | + file: './app/Dockerfile' |
| 163 | + push: true |
| 164 | + tags: ${{ env.APP_TAGS }} |
| 165 | + env: |
| 166 | + tags: ${{ env.APP_TAGS }} |
| 167 | +# runs-on: ubuntu-latest |
| 168 | +# permissions: |
| 169 | +# contents: write |
| 170 | +# packages: write |
| 171 | +# actions: write |
| 172 | +# pull-requests: write |
| 173 | +# checks: write |
| 174 | + |
| 175 | +# steps: |
| 176 | +# - name: Build docker |
| 177 | +# uses: Libertech-FR/lt-actions/release@main |
| 178 | +# with: |
| 179 | +# version_increment: ${{ github.event.inputs.version_increment }} |
| 180 | +# build_docker_image: ${{ github.event.inputs.build_docker_image }} |
| 181 | +# latest: ${{ github.event.inputs.latest }} |
| 182 | +# repository: ${{ github.repository }} |
| 183 | +# username: ${{ github.actor }} |
| 184 | +# password: ${{ secrets.GITHUB_TOKEN }} |
| 185 | +# github_token: ${{ secrets.ACTION_TOKEN }} |
| 186 | +# # Optional parameters, thoses are default values : |
| 187 | +# registry: 'ghcr.io' |
| 188 | +# context: ./service/ |
| 189 | +# is_branch_protected: true |
| 190 | + |
| 191 | +# build-app: |
| 192 | +# runs-on: ubuntu-latest |
| 193 | +# permissions: |
| 194 | +# contents: write |
| 195 | +# packages: write |
| 196 | + |
| 197 | +# steps: |
| 198 | +# - name: Build docker |
| 199 | +# uses: Libertech-FR/lt-actions/release@main |
| 200 | +# with: |
| 201 | +# version_increment: ${{ github.event.inputs.version_increment }} |
| 202 | +# build_docker_image: ${{ github.event.inputs.build_docker_image }} |
| 203 | +# latest: ${{ github.event.inputs.latest }} |
| 204 | +# repository: ${{ github.repository }} |
| 205 | +# username: ${{ github.actor }} |
| 206 | +# password: ${{ secrets.GITHUB_TOKEN }} |
| 207 | +# github_token: ${{ secrets.ACTION_TOKEN }} |
| 208 | +# # Optional parameters, thoses are default values : |
| 209 | +# registry: 'ghcr.io' |
| 210 | +# context: ./app/ |
| 211 | +# is_branch_protected: true |
0 commit comments