Mohammed Naser | 1de5519 | 2023-04-28 17:13:35 -0400 | [diff] [blame] | 1 | name: image |
| 2 | |
| 3 | on: |
| 4 | pull_request: |
| 5 | push: |
| 6 | branches: |
| 7 | - main |
| 8 | release: |
| 9 | types: |
| 10 | - published |
| 11 | |
Mohammed Naser | 55bbbf6 | 2023-04-28 22:24:55 +0000 | [diff] [blame] | 12 | permissions: |
| 13 | packages: write |
| 14 | contents: read |
| 15 | |
Mohammed Naser | 1de5519 | 2023-04-28 17:13:35 -0400 | [diff] [blame] | 16 | jobs: |
| 17 | build: |
| 18 | runs-on: ubuntu-latest |
| 19 | steps: |
| 20 | - name: Checkout project |
| 21 | uses: actions/checkout@v3 |
| 22 | |
| 23 | - name: Install Earthly |
| 24 | uses: earthly/actions-setup@v1 |
| 25 | with: |
| 26 | github-token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | |
Mohammed Naser | 55bbbf6 | 2023-04-28 22:24:55 +0000 | [diff] [blame] | 28 | - name: Login to GitHub Container Registry |
Mohammed Naser | 5c1338a | 2023-04-28 21:37:57 +0000 | [diff] [blame] | 29 | uses: docker/login-action@v2 |
| 30 | with: |
Mohammed Naser | 55bbbf6 | 2023-04-28 22:24:55 +0000 | [diff] [blame] | 31 | registry: ghcr.io |
| 32 | username: ${{ github.actor }} |
| 33 | password: ${{ secrets.GITHUB_TOKEN }} |
Mohammed Naser | 5c1338a | 2023-04-28 21:37:57 +0000 | [diff] [blame] | 34 | |
Mohammed Naser | 1de5519 | 2023-04-28 17:13:35 -0400 | [diff] [blame] | 35 | - name: Build image |
| 36 | run: earthly +image --tag ${{ github.sha }} |
| 37 | env: |
Mohammed Naser | 804d912 | 2023-04-28 22:01:40 +0000 | [diff] [blame] | 38 | EARTHLY_CI: true |
Mohammed Naser | 1de5519 | 2023-04-28 17:13:35 -0400 | [diff] [blame] | 39 | EARTHLY_PUSH: "${{ github.event_name == 'push' }}" |
Mohammed Naser | ccc70cc | 2023-04-28 22:20:34 +0000 | [diff] [blame] | 40 | EARTHLY_REMOTE_CACHE: ghcr.io/vexxhost/atmosphere:cache |
Mohammed Naser | 1de5519 | 2023-04-28 17:13:35 -0400 | [diff] [blame] | 41 | |
| 42 | publish: |
| 43 | runs-on: ubuntu-latest |
| 44 | if: github.event_name == 'release' |
| 45 | needs: |
| 46 | - build |
| 47 | steps: |
Mohammed Naser | 55bbbf6 | 2023-04-28 22:24:55 +0000 | [diff] [blame] | 48 | - name: Login to GitHub Container Registry |
Mohammed Naser | 1de5519 | 2023-04-28 17:13:35 -0400 | [diff] [blame] | 49 | uses: docker/login-action@v2 |
| 50 | with: |
Mohammed Naser | 55bbbf6 | 2023-04-28 22:24:55 +0000 | [diff] [blame] | 51 | registry: ghcr.io |
| 52 | username: ${{ github.actor }} |
| 53 | password: ${{ secrets.GITHUB_TOKEN }} |
Mohammed Naser | 1de5519 | 2023-04-28 17:13:35 -0400 | [diff] [blame] | 54 | |
| 55 | - name: Promote image |
| 56 | uses: akhilerm/tag-push-action@v2.1.0 |
| 57 | with: |
Mohammed Naser | ccc70cc | 2023-04-28 22:20:34 +0000 | [diff] [blame] | 58 | src: ghcr.io/vexxhost/atmosphere:${{ github.sha }} |
| 59 | dst: ghcr.io/vexxhost/atmosphere:${{ github.event.release.tag_name }} |