|
| 1 | +name: Cloudness Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + # Allows you to run this workflow manually from the Actions tab |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + REGISTRY: ghcr.io |
| 12 | + # github.repository as <account>/<repo> |
| 13 | + IMAGE_NAME: ${{ github.repository }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-push-app: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + # Sets the permissions for the GITHUB_TOKEN for security |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Log in to the Docker Hub |
| 28 | + uses: docker/login-action@v3 |
| 29 | + with: |
| 30 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 31 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Log in to GHCR |
| 34 | + uses: docker/login-action@v3 |
| 35 | + with: |
| 36 | + registry: ghcr.io |
| 37 | + username: ${{ github.actor }} |
| 38 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + - name: Extract metadata (tags, labels) for Docker |
| 41 | + id: meta |
| 42 | + uses: docker/metadata-action@v5 |
| 43 | + with: |
| 44 | + images: | |
| 45 | + ghcr.io/${{ github.repository }} |
| 46 | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} |
| 47 | + tags: | |
| 48 | + # on git tag push, create a tag with the version number (e.g., v1.2.3) |
| 49 | + type=ref,event=tag |
| 50 | + # on push to main, create the 'latest' tag |
| 51 | + type=raw,value=latest,enable={{is_default_branch}} |
| 52 | + # create a tag with the git sha for every push |
| 53 | + type=sha |
| 54 | +
|
| 55 | + - name: Build and push Cloudness App |
| 56 | + uses: docker/build-push-action@v5 |
| 57 | + with: |
| 58 | + context: . |
| 59 | + file: ./Dockerfile |
| 60 | + push: true |
| 61 | + tags: ${{ steps.meta.outputs.tags }} |
| 62 | + labels: ${{ steps.meta.outputs.labels }} |
| 63 | + # Pass build arguments for versioning |
| 64 | + # Extracts version from git tag e.g., v1.2.3 -> 1, 2, 3 |
| 65 | + build-args: | |
| 66 | + GIT_COMMIT=${{ github.sha }} |
| 67 | + CLOUDNESS_VERSION_MAJOR=${{ steps.meta.outputs.version && steps.meta.outputs.version.major || '0' }} |
| 68 | + CLOUDNESS_VERSION_MINOR=${{ steps.meta.outputs.version && steps.meta.outputs.version.minor || '0' }} |
| 69 | + CLOUDNESS_VERSION_PATCH=${{ steps.meta.outputs.version && steps.meta.outputs.version.patch || '0' }} |
| 70 | +
|
| 71 | + build-and-push-builder: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + # Sets the permissions for the GITHUB_TOKEN for security |
| 74 | + permissions: |
| 75 | + contents: read |
| 76 | + packages: write |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout repository |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Log in to the Docker Hub |
| 83 | + uses: docker/login-action@v3 |
| 84 | + with: |
| 85 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 86 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 87 | + |
| 88 | + - name: Log in to GHCR |
| 89 | + uses: docker/login-action@v3 |
| 90 | + with: |
| 91 | + registry: ghcr.io |
| 92 | + username: ${{ github.actor }} |
| 93 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + |
| 95 | + - name: Extract metadata (tags, labels) for Builder |
| 96 | + id: meta |
| 97 | + uses: docker/metadata-action@v5 |
| 98 | + with: |
| 99 | + images: | |
| 100 | + ghcr.io/${{ github.repository }}/builder |
| 101 | + ${{ secrets.DOCKERHUB_USERNAME }}/builder |
| 102 | + tags: | |
| 103 | + # on git tag push, create a tag with the version number (e.g., v1.2.3) |
| 104 | + type=ref,event=tag |
| 105 | + # on push to main, create the 'latest' tag |
| 106 | + type=raw,value=latest,enable={{is_default_branch}} |
| 107 | + # create a tag with the git sha for every push |
| 108 | + type=sha |
| 109 | +
|
| 110 | + - name: Build and push Builder Plugin |
| 111 | + uses: docker/build-push-action@v5 |
| 112 | + with: |
| 113 | + context: ./plugins/builder |
| 114 | + file: ./plugins/builder/Dockerfile |
| 115 | + push: true |
| 116 | + tags: ${{ steps.meta.outputs.tags }} |
| 117 | + labels: ${{ steps.meta.outputs.labels }} |
| 118 | + # Pass build arguments for versioning |
| 119 | + # Extracts version from git tag e.g., v1.2.3 -> 1, 2, 3 |
| 120 | + build-args: | |
| 121 | + GIT_COMMIT=${{ github.sha }} |
| 122 | + CLOUDNESS_VERSION_MAJOR=${{ steps.meta.outputs.version && steps.meta.outputs.version.major || '0' }} |
| 123 | + CLOUDNESS_VERSION_MINOR=${{ steps.meta.outputs.version && steps.meta.outputs.version.minor || '0' }} |
| 124 | + CLOUDNESS_VERSION_PATCH=${{ steps.meta.outputs.version && steps.meta.outputs.version.patch || '0' }} |
| 125 | +
|
| 126 | + upload-scripts: |
| 127 | + runs-on: ubuntu-latest |
| 128 | + needs: [build-and-push-app, build-and-push-builder] |
| 129 | + permissions: |
| 130 | + contents: read |
| 131 | + |
| 132 | + steps: |
| 133 | + - name: Checkout repository |
| 134 | + uses: actions/checkout@v4 |
| 135 | + |
| 136 | + - name: Extract version from tag |
| 137 | + id: version |
| 138 | + run: | |
| 139 | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 140 | + VERSION=${GITHUB_REF#refs/tags/} |
| 141 | + else |
| 142 | + VERSION="latest" |
| 143 | + fi |
| 144 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 145 | +
|
| 146 | + - name: Replace version placeholder in YAML files |
| 147 | + run: | |
| 148 | + sed -i "s|{{.App.Version}}|${{ steps.version.outputs.version }}|g" ./scripts/install/cloudness-app.yaml |
| 149 | +
|
| 150 | + - name: Upload Script files |
| 151 | + uses: ryand56/r2-upload-action@latest |
| 152 | + with: |
| 153 | + r2-account-id: ${{ secrets.SCRIPTS_BUCKET_ACCOUNT_ID }} |
| 154 | + r2-access-key-id: ${{ secrets.SCRIPTS_BUCKET_ACCESS_KEY_ID }} |
| 155 | + r2-secret-access-key: ${{ secrets.SCRIPTS_BUCKET_SECRET_ACCESS_KEY }} |
| 156 | + r2-bucket: ${{ secrets.SCRIPTS_BUCKET_NAME }} |
| 157 | + source-dir: ./scripts/install |
| 158 | + destination-dir: ./ |
0 commit comments