|
1 | 1 | name: CI
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - push: |
5 |
| - branches: [ master ] |
| 4 | + push: {} |
6 | 5 | pull_request:
|
7 | 6 | branches: [ master ]
|
8 | 7 |
|
@@ -59,29 +58,55 @@ jobs:
|
59 | 58 |
|
60 | 59 | deploy:
|
61 | 60 | name: Deploy
|
62 |
| - needs: test |
63 |
| - if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 61 | + needs: |
| 62 | + - test |
| 63 | + - lint |
64 | 64 | runs-on: ubuntu-latest
|
65 | 65 | steps:
|
66 | 66 |
|
67 | 67 | - name: Check out code into the Go module directory
|
68 | 68 | uses: actions/checkout@v2
|
69 |
| - |
70 |
| - - name: Push helm-operator image to Quay |
71 |
| - uses: docker/build-push-action@v1 |
| 69 | + with: |
| 70 | + fetch-depth: 0 |
| 71 | + |
| 72 | + - name: Prepare |
| 73 | + id: prep |
| 74 | + run: | |
| 75 | + TAG=ci |
| 76 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 77 | + TAG=${GITHUB_REF#refs/tags/} |
| 78 | + elif [[ $GITHUB_REF == refs/heads/* ]]; then |
| 79 | + TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') |
| 80 | + elif [[ $GITHUB_REF == refs/pull/* ]]; then |
| 81 | + TAG=pr-${{ github.event.number }} |
| 82 | + fi |
| 83 | +
|
| 84 | + echo ::set-output name=tag::${TAG} |
| 85 | + echo ::set-output name=platforms::linux/amd64,linux/arm64,linux/ppc64le,linux/s390x |
| 86 | +
|
| 87 | + - name: Set up Docker Buildx |
| 88 | + uses: docker/setup-buildx-action@v1 |
| 89 | + |
| 90 | + - name: Login to Quay |
| 91 | + if: github.event_name != 'pull_request' |
| 92 | + uses: docker/login-action@v1 |
72 | 93 | with:
|
73 | 94 | username: ${{ secrets.QUAY_USERNAME }}
|
74 | 95 | password: ${{ secrets.QUAY_PASSWORD }}
|
75 | 96 | registry: quay.io
|
76 |
| - repository: joelanford/helm-operator |
77 |
| - tags: master |
78 | 97 |
|
79 |
| - - name: Push example nginx-operator image to Quay |
80 |
| - uses: docker/build-push-action@v1 |
| 98 | + - name: Build helm-operator image |
| 99 | + uses: docker/build-push-action@v2 |
81 | 100 | with:
|
82 |
| - path: example/ |
83 |
| - username: ${{ secrets.QUAY_USERNAME }} |
84 |
| - password: ${{ secrets.QUAY_PASSWORD }} |
85 |
| - registry: quay.io |
86 |
| - repository: joelanford/nginx-operator |
87 |
| - tags: latest |
| 101 | + context: . |
| 102 | + platforms: ${{ steps.prep.outputs.platforms }} |
| 103 | + push: ${{ github.event_name != 'pull_request' }} |
| 104 | + tags: quay.io/joelanford/helm-operator:${{ steps.prep.outputs.tag }} |
| 105 | + |
| 106 | + - name: Build example nginx-operator image |
| 107 | + uses: docker/build-push-action@v2 |
| 108 | + with: |
| 109 | + context: ./example |
| 110 | + platforms: ${{ steps.prep.outputs.platforms }} |
| 111 | + push: ${{ github.event_name != 'pull_request' }} |
| 112 | + tags: quay.io/joelanford/nginx-operator:${{ steps.prep.outputs.tag }} |
0 commit comments