Skip to content

Commit 864189f

Browse files
committed
fix: revert using cache repository
1 parent 6bdfbb9 commit 864189f

1 file changed

Lines changed: 69 additions & 7 deletions

File tree

.github/workflows/build-and-push.yml

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- '*'
88
workflow_dispatch: ~
99
env:
10+
CACHE_REGISTRY: ghcr.io
11+
CACHE_REPO: linode/apl-nodejs-helloworld
1012
REPO: linode/apl-nodejs-helloworld
1113
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
1214
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
@@ -38,20 +40,80 @@ jobs:
3840
uses: actions/checkout@v6
3941
- name: Set up Docker Buildx
4042
uses: docker/setup-buildx-action@v3
41-
with:
42-
driver: docker
43-
- name: Login to Docker hub
43+
- name: Login to Github Packages
4444
uses: docker/login-action@v3
4545
with:
46-
username: ${{ env.DOCKER_USERNAME }}
47-
password: ${{ env.DOCKER_PASSWORD }}
46+
registry: ${{ env.CACHE_REGISTRY }}
47+
username: ${{ env.BOT_USERNAME }}
48+
password: '${{ secrets.BOT_TOKEN }}'
4849
- name: CI tests, image build and push tag for main or branch
4950
uses: docker/build-push-action@v6
5051
with:
5152
push: true
52-
provenance: false
5353
build-args: |
5454
APPS_REVISION=${{ env.APPS_REVISION }}
5555
context: .
5656
tags: |
57-
${{ env.REPO }}:${{ env.TAG }}
57+
${{ env.CACHE_REGISTRY }}/${{ env.CACHE_REPO }}:${{ env.TAG }}
58+
59+
push-to-docker:
60+
needs: build-test-cache
61+
if: always() && ((contains(needs.build-test-cache.result, 'success') && !contains(needs.integration.outputs.started, 'true')) || (contains(needs.integration.result, 'success'))) && !github.event.act && github.actor != 'dependabot[bot]'
62+
runs-on: ubuntu-22.04
63+
steps:
64+
- name: Push to docker hub
65+
run: |
66+
set -u
67+
TAG=${GITHUB_REF##*/}
68+
docker login ghcr.io -u $BOT_USERNAME -p ${{ secrets.BOT_TOKEN }}
69+
image="$CACHE_REGISTRY/$CACHE_REPO:$TAG"
70+
docker pull $image
71+
docker tag $image $REPO:$TAG
72+
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
73+
docker push $REPO:$TAG
74+
- name: Show me the logic
75+
run: |
76+
echo github.ref == ${{ github.ref }}
77+
78+
release:
79+
needs: push-to-docker
80+
if: always() && (startsWith(github.ref, 'refs/heads/releases/') || startsWith(github.ref, 'refs/heads/main')) && startsWith(github.event.head_commit.message, 'chore(release)') && !github.event.act
81+
runs-on: ubuntu-22.04
82+
env:
83+
COMMIT_MSG: ${{ github.event.head_commit.message }}
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v6
87+
- name: Set env
88+
run: |
89+
git config --global user.email $BOT_EMAIL
90+
git config --global user.name $BOT_USERNAME
91+
- name: Create and push git tag
92+
id: git_tag
93+
run: |
94+
TAG=${GITHUB_REF##*/}
95+
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
96+
docker pull $REPO:$TAG
97+
docker tag $REPO:$TAG $REPO:latest
98+
docker push $REPO:latest
99+
release_tag=v$(jq -r '.version' < package.json)
100+
echo tag=$release_tag >> $GITHUB_OUTPUT
101+
echo "Releasing $REPO:$release_tag"
102+
docker tag $REPO:$TAG $REPO:$release_tag
103+
docker push $REPO:$release_tag
104+
docker login -u $BOT_USERNAME -p '${{ secrets.BOT_TOKEN }}' ghcr.io
105+
docker tag $REPO:$TAG $CACHE_REGISTRY/$CACHE_REPO:$release_tag
106+
docker push $CACHE_REGISTRY/$CACHE_REPO:$release_tag
107+
echo "machine github.com login ${{ env.BOT_USERNAME }} password ${{ secrets.BOT_TOKEN }}" > ~/.netrc
108+
git tag -am "$COMMIT_MSG" $release_tag && git push --follow-tags
109+
#Cut the CHANGELOG.md file up to the first occurence of the "### \[[0-9]*" (meaning three #, a space,a square bracket and any number after it)
110+
sed -n '/### \[[0-9]*/q;p' CHANGELOG.md > NEW_CHANGELOG.md
111+
- name: Create GitHub release
112+
uses: ncipollo/release-action@v1.20.0
113+
env:
114+
token: ${{ secrets.GITHUB_TOKEN }}
115+
with:
116+
tag: ${{ steps.git_tag.outputs.tag }}
117+
name: Release ${{ steps.git_tag.outputs.tag }}
118+
bodyFile: 'NEW_CHANGELOG.md'
119+
generateReleaseNotes: true

0 commit comments

Comments
 (0)