github.com/df-mc/dragonfly@v0.9.13/.github/workflows/push.yml (about)

     1  name: Build and deploy
     2  on: [push]
     3  jobs:
     4  
     5    build:
     6      name: Build
     7      runs-on: ubuntu-latest
     8      steps:
     9  
    10        - name: Check out code into the Go module directory
    11          uses: actions/checkout@v3
    12  
    13        - name: Set up Go 1.21
    14          uses: actions/setup-go@v5
    15          with:
    16            go-version: 1.21
    17          id: go
    18  
    19        - name: Get dependencies
    20          run: |
    21            mkdir -p $GOPATH/bin
    22            export PATH=$PATH:$GOPATH/bin
    23  
    24        - name: Build
    25          run: go build -o dragonfly_exe -v .
    26  
    27        - name: Vet
    28          run: go vet ./...
    29  
    30        - name: Formatting
    31          run: test -z $(go fmt ./...)
    32  
    33        - name: Staticcheck
    34          uses: dominikh/staticcheck-action@v1.3.0
    35          with:
    36            install-go: false
    37  
    38    deploy:
    39      name: Deploy
    40      needs: build
    41      runs-on: ubuntu-latest
    42      steps:
    43  
    44        - name: Set up Go 1.21
    45          uses: actions/setup-go@v5
    46          with:
    47            go-version: 1.21
    48          id: go
    49  
    50        - name: Check out code into the Go module directory
    51          uses: actions/checkout@v3
    52  
    53        - name: Get dependencies
    54          run: |
    55            mkdir -p $GOPATH/bin
    56            export PATH=$PATH:$GOPATH/bin
    57  
    58        - name: Build
    59          run: go build -o dragonfly_exe -v .
    60  
    61        - name: Set SSH info
    62          env:
    63            SSH_KNOWN_HOSTS: ${{ secrets.VPS_KNOWN_HOSTS }}
    64            SSH_PRIVATE_KEY: ${{ secrets.VPS_PRIVATE_KEY }}
    65          run: |
    66            mkdir -p ~/.ssh/
    67            echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    68            echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
    69            chmod 600 ~/.ssh/id_rsa
    70  
    71        - name: Stop server
    72          env:
    73            HOST: ${{ secrets.VPS_HOST }}
    74          run: |
    75            ssh -i ~/.ssh/id_rsa $HOST screen -d -R -S dragonfly -X stuff '^C'
    76            ssh -i ~/.ssh/id_rsa $HOST rm -f dragonfly_exe
    77  
    78        - name: Transfer executable
    79          env:
    80            HOST: ${{ secrets.VPS_HOST }}
    81          run: |
    82            scp -i ~/.ssh/id_rsa dragonfly_exe $HOST:/home/dragonfly_exe
    83  
    84        - name: Restart server
    85          env:
    86            HOST: ${{ secrets.VPS_HOST }}
    87          run: |
    88            ssh -i ~/.ssh/id_rsa $HOST "screen -d -R -S dragonfly -X stuff '/home/dragonfly_exe\n'"
    89  
    90    update_contributors:
    91      name: Update Contributors
    92      runs-on: ubuntu-latest
    93      if: github.ref == 'refs/heads/master'
    94      steps:
    95        - name: Checkout Repository
    96          uses: actions/checkout@v3
    97        - name: Fetch Contributors
    98          run: |
    99            CONTRIBUTOR_DATA=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/df-mc/dragonfly/contributors?per_page=9999)
   100            echo $CONTRIBUTOR_DATA
   101            if [ $(echo $CONTRIBUTOR_DATA | jq type) == '"array"' ]; then echo -e "// Code generated by .github/workflows/push.yml; DO NOT EDIT\n\npackage session\n\n// enchantNames are names translated to the 'Standard Galactic Alphabet' client-side. The names generally have no meaning\n// on the vanilla server implementation, so we can sneak some easter eggs in here without anyone noticing.\nvar enchantNames = []string{"$(echo $CONTRIBUTOR_DATA | jq .[].login | sed -r -e "s/([^A-Z\"])([A-Z])/\1 \2/g" | sed "s/./\L&/g" | sort | sed -z "s/\n/,/g")"}" > server/session/enchantment_texts.go && gofmt -w server/session/enchantment_texts.go; fi
   102        - name: Push Changes
   103          uses: stefanzweifel/git-auto-commit-action@v5
   104          with:
   105            commit_message: "updated contributor list"