blob: 59ff7b4b5804b6e1a307172a40364534d712d27a [file] [log] [blame]
Mohammed Naser1de55192023-04-28 17:13:35 -04001name: image
2
3on:
4 pull_request:
5 push:
6 branches:
7 - main
8 release:
9 types:
10 - published
11
Mohammed Naser55bbbf62023-04-28 22:24:55 +000012permissions:
13 packages: write
14 contents: read
15
Mohammed Naser1de55192023-04-28 17:13:35 -040016jobs:
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 Naser55bbbf62023-04-28 22:24:55 +000028 - name: Login to GitHub Container Registry
Mohammed Naser5c1338a2023-04-28 21:37:57 +000029 uses: docker/login-action@v2
30 with:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000031 registry: ghcr.io
32 username: ${{ github.actor }}
33 password: ${{ secrets.GITHUB_TOKEN }}
Mohammed Naser5c1338a2023-04-28 21:37:57 +000034
Mohammed Naser1de55192023-04-28 17:13:35 -040035 - name: Build image
36 run: earthly +image --tag ${{ github.sha }}
37 env:
Mohammed Naser804d9122023-04-28 22:01:40 +000038 EARTHLY_CI: true
Mohammed Naser1de55192023-04-28 17:13:35 -040039 EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
Mohammed Naserccc70cc2023-04-28 22:20:34 +000040 EARTHLY_REMOTE_CACHE: ghcr.io/vexxhost/atmosphere:cache
Mohammed Naser1de55192023-04-28 17:13:35 -040041
42 publish:
43 runs-on: ubuntu-latest
44 if: github.event_name == 'release'
45 needs:
46 - build
47 steps:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000048 - name: Login to GitHub Container Registry
Mohammed Naser1de55192023-04-28 17:13:35 -040049 uses: docker/login-action@v2
50 with:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000051 registry: ghcr.io
52 username: ${{ github.actor }}
53 password: ${{ secrets.GITHUB_TOKEN }}
Mohammed Naser1de55192023-04-28 17:13:35 -040054
55 - name: Promote image
56 uses: akhilerm/tag-push-action@v2.1.0
57 with:
Mohammed Naserccc70cc2023-04-28 22:20:34 +000058 src: ghcr.io/vexxhost/atmosphere:${{ github.sha }}
59 dst: ghcr.io/vexxhost/atmosphere:${{ github.event.release.tag_name }}