|
1 | | -name: generic |
| 1 | +name: Generic github actions |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - '!master' |
7 | | - pull_request: |
8 | | - branches: |
9 | | - - '*' |
| 5 | + branches-ignore: |
| 6 | + - 'master' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
10 | 10 |
|
11 | 11 | jobs: |
12 | 12 | build-devel: |
13 | 13 | runs-on: ubuntu-latest |
14 | | - |
15 | 14 | steps: |
16 | 15 | - name: Get current date |
17 | | - id: date |
18 | | - run: echo "::set-output name=date::$(TZ='Asia/Jakarta' date +'%Y%m%d%H%M')" |
19 | | - - uses: actions/checkout@v1 |
20 | | - - name: Build Development release |
| 16 | + run: echo "irgsh_build_date=$(TZ='Asia/Jakarta' date +'%Y%m%d%H%M')" >> $GITHUB_ENV |
| 17 | + - uses: actions/checkout@v3 |
| 18 | + - name: Install needed apt packages |
| 19 | + uses: awalsh128/cache-apt-pkgs-action@v1.2.3 |
| 20 | + with: |
| 21 | + packages: gpg pbuilder debootstrap devscripts python3-apt reprepro make |
| 22 | + version: 1.0 |
| 23 | + - uses: actions/setup-go@v3 |
| 24 | + with: |
| 25 | + go-version: '1.13.14' |
| 26 | + - uses: actions/cache@v3 |
| 27 | + with: |
| 28 | + path: | |
| 29 | + ~/.cache/go-build |
| 30 | + ~/go/pkg/mod |
| 31 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 32 | + restore-keys: | |
| 33 | + ${{ runner.os }}-go- |
| 34 | + - name: Build development release |
21 | 35 | run: | |
22 | | - sudo apt update && sudo apt install -y gpg pbuilder debootstrap devscripts python-apt reprepro make |
23 | | - curl -O https://storage.googleapis.com/golang/go1.13.14.linux-amd64.tar.gz |
24 | | - tar -xf go1.13.14.linux-amd64.tar.gz |
25 | | - sudo mv go /usr/local |
26 | | - echo ${{ steps.date.outputs.date }}-development-build > VERSION |
| 36 | + echo ${{ env.irgsh_build_date }}-development-build > VERSION |
27 | 37 | make release |
28 | 38 | mv target/{release,pre-release}.tar.gz |
29 | | - - uses: actions/upload-artifact@master |
| 39 | + - uses: actions/upload-artifact@v3 |
30 | 40 | with: |
31 | 41 | name: pre-release.tar.gz |
32 | 42 | path: target/ |
33 | | - - name: Create Release |
34 | | - id: create_release |
35 | | - uses: actions/create-release@v1 |
36 | | - env: |
37 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token |
| 43 | + outputs: |
| 44 | + irgsh_build_date: ${{ env.irgsh_build_date }} |
| 45 | + |
| 46 | + release: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: [build-devel] |
| 49 | + steps: |
| 50 | + - uses: actions/download-artifact@v3 |
38 | 51 | with: |
39 | | - tag_name: ${{ steps.date.outputs.date }} |
40 | | - release_name: ${{ steps.date.outputs.date }} Development Release |
41 | | - body: | |
42 | | - Development release ${{ steps.date.outputs.date }} |
| 52 | + name: pre-release.tar.gz |
| 53 | + - name: Extract pre-release |
| 54 | + run: | |
| 55 | + tar xvzf pre-release.tar.gz |
| 56 | + cp $(find . -type f -name "irgsh-cli") . |
| 57 | + - name: Create github pre-release |
| 58 | + uses: softprops/action-gh-release@v0.1.15 |
| 59 | + with: |
| 60 | + name: ${{ needs.build-devel.outputs.irgsh_build_date }} Development Release |
| 61 | + body: Development release ${{ needs.build-devel.outputs.irgsh_build_date }} |
43 | 62 | draft: false |
44 | 63 | prerelease: true |
45 | | - - name: Upload Full Release Asset |
46 | | - id: upload-full-release-asset |
47 | | - uses: actions/upload-release-asset@v1 |
48 | | - env: |
49 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
50 | | - with: |
51 | | - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps |
52 | | - asset_path: ./target/pre-release.tar.gz |
53 | | - asset_name: pre-release.tar.gz |
54 | | - asset_content_type: application/tar+gzip |
55 | | - - name: Upload CLI Release |
56 | | - id: upload-cli-release-asset |
57 | | - uses: actions/upload-release-asset@v1 |
58 | | - env: |
59 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
60 | | - with: |
61 | | - upload_url: ${{ steps.create_release.outputs.upload_url }} |
62 | | - asset_path: ./irgsh-go/usr/bin/irgsh-cli |
63 | | - asset_name: irgsh-cli |
64 | | - asset_content_type: application/x-executable |
| 64 | + tag_name: ${{ needs.build-devel.outputs.irgsh_build_date }}-development-build |
| 65 | + files: | |
| 66 | + pre-release.tar.gz |
| 67 | + irgsh-cli |
65 | 68 |
|
66 | 69 | deploy: |
67 | 70 | runs-on: ubuntu-latest |
68 | | - needs: [build-devel] |
| 71 | + needs: [release] |
69 | 72 | steps: |
70 | | - - name: Deployment |
71 | | - env: |
72 | | - HOST: ${{secrets.RAFI_HOSTNAME}} |
73 | | - KEY: ${{secrets.RAFI_DEPLOYMENT_KEY}} |
74 | | - run: | |
75 | | - curl --header "Content-Type: application/json" --request POST --data "{\"name\":\"irgsh-dev\",\"token\": \""$KEY"\"}" https://$HOST/tendang |
| 73 | + - name: Deploy to irgsh development server |
| 74 | + uses: kudaliar032/tendang-action@v1 |
| 75 | + with: |
| 76 | + url: ${{ secrets.RAFI_TENDANG_URL }} |
| 77 | + token: ${{ secrets.RAFI_DEPLOYMENT_KEY }} |
| 78 | + name: ${{ secrets.RAFI_DEPLOYMENT_NAME }} |
0 commit comments