|
1 | 1 | name: Build Image |
2 | 2 |
|
3 | | -on: [push, pull_request, workflow_dispatch] |
| 3 | +on: [push, pull_request_target, workflow_dispatch] |
4 | 4 |
|
5 | 5 | env: |
| 6 | + GITHUB_REPO: "linuxserver/docker-mods" #don't modify |
6 | 7 | ENDPOINT: "linuxserver/mods" #don't modify |
7 | 8 | BASEIMAGE: "code-server" #replace |
8 | 9 | MODNAME: "dotnet" #replace |
9 | 10 |
|
10 | 11 | jobs: |
11 | | - build: |
| 12 | + set-vars: |
12 | 13 | runs-on: ubuntu-latest |
13 | 14 | steps: |
14 | | - |
15 | | - |
16 | | - - name: Build image |
| 15 | + - name: Set Vars |
| 16 | + id: outputs |
17 | 17 | run: | |
18 | | - # Set version |
| 18 | + echo "GITHUB_REPO=${{ env.GITHUB_REPO }}" >> $GITHUB_OUTPUT |
| 19 | + echo "ENDPOINT=${{ env.ENDPOINT }}" >> $GITHUB_OUTPUT |
| 20 | + echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT |
| 21 | + echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT |
| 22 | + # **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. **** |
19 | 23 | DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)" |
20 | | - DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="active" or ."support-phase"=="maintenance") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)" |
21 | | - DOTNET_TAG="$(echo $DOTNET_VERSIONS | tr ' ' '_')" |
22 | | - echo "DOTNET_TAG=${DOTNET_TAG}" >> $GITHUB_ENV |
23 | | - # Build image |
24 | | - docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${{ github.sha }} . |
25 | | -
|
26 | | - - name: Tag image |
27 | | - if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }} |
28 | | - run: | |
29 | | - docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME} |
30 | | - docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} |
31 | | - docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} |
32 | | - docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} |
33 | | - docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} |
34 | | - docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} |
35 | | - docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} |
36 | | - docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} |
37 | | -
|
38 | | - - name: Credential check |
39 | | - if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }} |
40 | | - run: | |
41 | | - echo "CR_USER=${{ secrets.CR_USER }}" >> $GITHUB_ENV |
42 | | - echo "CR_PAT=${{ secrets.CR_PAT }}" >> $GITHUB_ENV |
43 | | - echo "DOCKERUSER=${{ secrets.DOCKERUSER }}" >> $GITHUB_ENV |
44 | | - echo "DOCKERPASS=${{ secrets.DOCKERPASS }}" >> $GITHUB_ENV |
45 | | - if [[ "${{ secrets.CR_USER }}" == "" && "${{ secrets.CR_PAT }}" == "" && "${{ secrets.DOCKERUSER }}" == "" && "${{ secrets.DOCKERPASS }}" == "" ]]; then |
46 | | - echo "::error::Push credential secrets missing." |
47 | | - echo "::error::You must set either CR_USER & CR_PAT or DOCKERUSER & DOCKERPASS as secrets in your repo settings." |
48 | | - echo "::error::See https://github.com/linuxserver/docker-mods/blob/master/README.md for more information/instructions." |
49 | | - exit 1 |
50 | | - fi |
51 | | -
|
52 | | - - name: Login to GitHub Container Registry |
53 | | - if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }} |
54 | | - run: | |
55 | | - echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.CR_USER }} --password-stdin |
56 | | -
|
57 | | - - name: Push tags to GitHub Container Registry |
58 | | - if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }} |
59 | | - run: | |
60 | | - docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} |
61 | | - docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} |
62 | | - docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} |
63 | | - docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} |
| 24 | + MOD_VERSION="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="active" or ."support-phase"=="maintenance") | ."latest-sdk"' | tr '\n' '_' | head -c -1)" |
| 25 | + echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT |
| 26 | + outputs: |
| 27 | + GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }} |
| 28 | + ENDPOINT: ${{ steps.outputs.outputs.ENDPOINT }} |
| 29 | + BASEIMAGE: ${{ steps.outputs.outputs.BASEIMAGE }} |
| 30 | + MODNAME: ${{ steps.outputs.outputs.MODNAME }} |
| 31 | + MOD_VERSION: ${{ steps.outputs.outputs.MOD_VERSION }} |
64 | 32 |
|
65 | | - - name: Login to DockerHub |
66 | | - if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }} |
67 | | - run: | |
68 | | - echo ${{ secrets.DOCKERPASS }} | docker login -u ${{ secrets.DOCKERUSER }} --password-stdin |
69 | | -
|
70 | | - - name: Push tags to DockerHub |
71 | | - if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }} |
72 | | - run: | |
73 | | - docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} |
74 | | - docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} |
75 | | - docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} |
76 | | - docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME} |
| 33 | + build: |
| 34 | + uses: linuxserver/github-workflows/.github/workflows/docker-mod-builder.yml@v1 |
| 35 | + needs: set-vars |
| 36 | + secrets: |
| 37 | + CR_USER: ${{ secrets.CR_USER }} |
| 38 | + CR_PAT: ${{ secrets.CR_PAT }} |
| 39 | + DOCKERUSER: ${{ secrets.DOCKERUSER }} |
| 40 | + DOCKERPASS: ${{ secrets.DOCKERPASS }} |
| 41 | + with: |
| 42 | + GITHUB_REPO: ${{ needs.set-vars.outputs.GITHUB_REPO }} |
| 43 | + ENDPOINT: ${{ needs.set-vars.outputs.ENDPOINT }} |
| 44 | + BASEIMAGE: ${{ needs.set-vars.outputs.BASEIMAGE }} |
| 45 | + MODNAME: ${{ needs.set-vars.outputs.MODNAME }} |
| 46 | + MOD_VERSION: ${{ needs.set-vars.outputs.MOD_VERSION }} |
0 commit comments