Ireland edge out Afghanistan in T20 opener with ball to spare